How to select concatenate columns with Laravel Query Builder?

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Today now in this post i wills how you how to select concatenate columns with Laravel Query Builder? We are always need to use sql query for concatenate full name or something to concatenate by using mysql concatenate function, now if we think how to use concatenate function in laravel query builder then now this post will help you.

So, if we need to use concatenate mysql function then you can see bellow example:

Example:

$user = User::select("users.*",DB::raw("CONCAT(users.first_name,'',users.last_name) as full_name"))
->get();
print_r($user);

Read Also : How to convert Object into Array in PHP?

Thanks for read. I hope it help you. For more you can follow us on facebook.

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →