I'm working with Laravel 5.3 and in a Model Post
, I have an appends attributes :
/*
* toJson
*/
protected $appends = ['count'];
And the magic method :
public function getCountAttribute()
{
return Offer::where('id', '=', $this->id)->count();
}
So, when I get a Post
model with eloquent like Post::get()
, and get the return with json for example, I ALWAYS have this attribute count
in my object.
How can I specify if I want or not this or another appends atribute ?
Post::get()
isn't a valid method, do you meanall
? – Styphon