Closed allanvobraun closed 3 years ago
https://github.com/alijumaan/Laravel-Ecommerce/blob/42abb71ca559e8b06aad4c76a2fd22a13ed5bd84/app/Models/User.php#L72
It is possible to use the laravel Accesor syntax here and in other methods. So there is no need to invoke a function every time you need the value. This is completely optional, but I consider it a good practice ...
Reference: https://laravel.com/docs/8.x/eloquent-mutators#accessors-and-mutators
Example:
public function getFullNameAttribute() { return "{$this->first_name} {$this->last_name}"; }
Usage : $model->full_name
$model->full_name
I agree with you
https://github.com/alijumaan/Laravel-Ecommerce/blob/42abb71ca559e8b06aad4c76a2fd22a13ed5bd84/app/Models/User.php#L72
It is possible to use the laravel Accesor syntax here and in other methods. So there is no need to invoke a function every time you need the value. This is completely optional, but I consider it a good practice ...
Reference: https://laravel.com/docs/8.x/eloquent-mutators#accessors-and-mutators