vendredi 28 juillet 2017

Get Calculated Field from Eloquent only when it was declared

I'm working with Eloquent and Laravel 5, added a field at $appends attribute on model and a mutator to get it value. My issue is, how get this field only when it is called?

    public static $model = 'Model';
    protected $table = 'table';
    protected $primaryKey = 'idtable';   
    public $incrementing = false;
    public $timestamps = false;

    protected $appends = ['DescComposta'];

    //Mutators
    public function getDescCompostaAttribute()
    {
        return $this->attributes['desc_composta'] = 'yes';
    }

Thank you all!



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2u4yi8s
via IFTTT

Aucun commentaire:

Enregistrer un commentaire