How to make a concatenate in Laravel select using Query Builder

If you want to make a concatenate between 2 columns inside of your select in Laravel you can simply use DB::raw(‘CONCAT(…

Here is an example

User::select(
          'id',
          DB::raw('CONCAT(first_name," ",last_name) as full_name')
        )
       ->orderBy('full_name')
       ->get();

Leave a Reply

Your email address will not be published. Required fields are marked *