If I'm creating custom output for my model should I use a method or a ghost attribute. Lets say my DB has columns first_name and last_name and I want to access them as fullName in my view. Which is better:
//Model
public function fullName()
{
return $this->first_name . ' ' . $this->last_name;
}
//View
Or
//Model
public function getFullNameAttribute()
{
return $this->first_name . ' ' . $this->last_name;
}
//View
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iDdsHs
via IFTTT
Aucun commentaire:
Enregistrer un commentaire