laravel search and return record with pagination

Solutions on MaxInterview for laravel search and return record with pagination by the best coders in the world

showing results for - "laravel search and return record with pagination"
Roberto
05 May 2016
1//make sure that all your queries/builder has ->paginate and not a ->get() or 
2//->first() then do {{ $var->links() }} in the blade
3
4        if(empty($request->search)){
5            $user = DB::table('users')->Paginate(15);
6            return view('/users', ['user' => $user]);
7        }else{
8            $user = DB::table('users')->where('name', 'like', '%'. $request->search .'%')->Paginate(15);
9            return view('/users', ['user' => $user]);
10        }