mvpop
4 months ago

Eloquent search

Posted 4 months ago by mvpop

Hey guys,

I feel like there's a cleaner way to write this:

 $fullName_1 = DB::raw("CONCAT(`FirstName`, ' ', `LastName`)");
 $fullName_2 = DB::raw("CONCAT(`LastName`, ' ', `FirstName`)");

        $customers = Customers::where($fullName_1, 'like', "%$query%")
                                ->orWhere($fullName_2, 'like', "%$query%")
                                ->orderBy('id', 'asc')
                                ->paginate(10);

Any thoughts?

Thanks

Please sign in or create an account to participate in this conversation.