Posted on Arjun

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.

I am Arjun from Hyderabad (India). I have been working as a software engineer from last 7+ years, and its my passion to learn new things and implement them as a practice. Aside from work, I likes gardening and spending time with pets. Protection Status