Laravel – Get the full name of a User using Eloquent accessors

Almost in all projects we face this situation where we have first name and last name in two different fields in the database table and we need to combine the names to show users full in the front end.For each project we implement different solution based on the Framework by fallowing DRY principles.

Here today i am gonna show you show to use laravel’s Eloquent accessors for getting full name of the user.Below is example – Here is my user model, and first_name and last_name are the columns in my user table.

How to use

You can access the full name of user same of accessing other methods of user model.

That’s it.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 vote
Article Rating
Notify of
1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
Manuel Ruiz
Manuel Ruiz
1 year ago

Thanks, worked great (Laravel 6) Protection Status
Would love your thoughts, please comment.x