Wednesday 15 April 2015

php - Is it possible to still use Laravel 5 Accessors to access multiple attributes -



php - Is it possible to still use Laravel 5 Accessors to access multiple attributes -

perhaps i'm missing obvious here if do:

public function getname() { homecoming $this->first_name . ' ' . $this->last_name; }

and in view do

$user->name

i nil back. if run

$user->getname()

then works expected. not possible create accessor accesses multiple attributes?

you should utilize in user model accesor:

public function getnameattribute($value) { homecoming $this->first_name . ' ' . $this->last_name; }

so can utilize $user->name property. name format getpropertyattribute.

php model accessor laravel-5

No comments:

Post a Comment