1
I have a mutator similar to this:
public function getLastTotalAttribute()
{
return $this->produto->sold_on_register;
}
I want the last_total attribute to be automatically generated in the query, as well as the common attributes of $fillable
.
I need to use Collection via API and no longer have access to the properties of the object when I do this.
EDIT 1:
To simplify understanding:
Users have product, and the product has the sold_on_register.
I want to have access to the product attribute through the user, however, I will not do it in Lade to be able to use the mutator method, I need this attribute to be inserted by default.
Example:
User::find(1)
will have common user attributes
User::find(1)->last_total
access the mutator attribute if I do this in the Blade or controller.
I need last_total to be included in the attributes naturally in User::find(1)
for the API.