mercredi 31 mars 2021

How to create search filter while paginate in laravel 5? [duplicate]

$lists = UserRoles::where('role_id', '!=',1)
    ->whereHas('users', function($offerQuery) use ($search){
        $offerQuery->where(function ($q) use($search) {
            $q->where('user_name', 'LIKE', '%',$search.'%')
            ->orWhere('user_mobile_number', 'like', '%' . $search . '%');
        });
        $offerQuery->where('user_status', '!=', 'Delete');
    })->paginate(50);

In the above query what am I trying to do is if I try this query without search filter then It works but I also want a search filter and when I hit this query then it shows Undefined variable: search. I don't know why? Please help me.

Thank You



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire