mercredi 29 mars 2017

Add custom atrribute to json response

I have model something like that with custom attribute

class MyModel extends Model
{
    public function getExtraAttribute(){
        return 'some string'; //etc.
    }
}

And for controller method i have this

return MyModel::where('user_id', Auth::user()->id)->get();

But i don't see 'extra' attribute on json response

P.s. extra isn't column from database.



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

Aucun commentaire:

Enregistrer un commentaire