I have a DB table with a column "visible" (true/false).
The Eloquent model already has a property visible, see this code snippet taken from Illuminate\Database\Eloquent\Model.
/**
* The attributes that should be visible in arrays.
*
* @var array
*/
protected $visible = array();
When printing out the model, the "visible" property is the already existing array instead of the column value. Is there a way to rename the column in the Model? I already tried this (found here: http://laravel.com/docs/4.2/eloquent#accessors-and-mutators)
public function setVisibleAttribute($value) {
$this->attributes['isvisible'] = $value;
}
public function getVisibleAttribute($value) {
$this->attributes['isvisible'];
}
I know I can solve the problem like this:
User::select('id', 'name', 'visible as isVisible')->get();
I was just wondering if there isn't a really built in mechanism.
Important note: the DB is also used by existing software so renaming it isn't really an option.