Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel search and return record with pagination

//make sure that all your queries/builder has ->paginate and not a ->get() or 
//->first() then do {{ $var->links() }} in the blade

        if(empty($request->search)){
            $user = DB::table('users')->Paginate(15);
            return view('/users', ['user' => $user]);
        }else{
            $user = DB::table('users')->where('name', 'like', '%'. $request->search .'%')->Paginate(15);
            return view('/users', ['user' => $user]);
        }
 
PREVIOUS NEXT
Tagged: #laravel #search #return #record #pagination
ADD COMMENT
Topic
Name
3+9 =