I have a model with one accessor defined. If I call the accessor it runs well but I'd like the accessor to execute each time the model is retrieved so I can replace attribute value with the accessor returned value.
This is my model:
protected $appends = ['name']; // Read on inernet that this would do the trick but don't
public function getNameAttribute($value){
return ($value." - ".$this->doors->num_doors." - ".$this->body->name);
}
Now the accessor it's just executed when I access to the name attribue.
I'm working with Laravel 5.7
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire