In this tutorial, I will give you an example of “How to search for first name and last name in Join Query in Laravel,” so you can easily apply it to your Laravel 5, Laravel 6, Laravel 7, Laravel 8, Laravel 9, and Laravel 10 applications.
Search first_name + last_name from one input tag Laravel
users table:
schedule_interviews table:
if($request->searchTerm)
{
$userList = ScheduleInterview::select(['schedule_interviews.*','users.first_name as user_first_name'])
->join('users','schedule_interviews.applicant_id', '=', 'users.id')
->where('first_name', 'like', '%'.$request->searchTerm.'%')
->orWhere('last_name', 'like', '%'.$request->searchTerm.'%')
->orWhereRaw("concat(first_name, ' ', last_name) like '%$request->searchTerm%' ")
->paginate(10);
return view('candidate',[
'userList' => $userList ?? '',]);
}
I hope that this article helped you learn How to search by full name if first name and last name are in different columns in the Laravel application. You may also want to check out our guide on Adding custom font in dompdf in Laravel.