How to Search for first name and last name in Join Query in Laravel?

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

Search first_name + last_name from one input tag Laravel
search by full name if first name and last name are in different columns in the Laravel application
        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.

Hi, My name is Gaurav Pandey. I'm a Laravel developer, owner of 8Bityard. I live in Uttarakhand - India and I love to write tutorials and tips that can help other developers. I am a big fan of PHP, Javascript, JQuery, Laravel, WordPress. connect@8bityard.com

Scroll to Top