Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if( \Request::ajax() ){
- // Resource tem pesquisa ajax, Filtrar e retornar a view
- if( \Request::has('filter') == false )
- return null; // Não tem filtro válido, cancela ( ainda não tratei essa parte... TODO )
- $filter = \Request::get('filter');
- $data = User::where('name', 'like', "%{$filter}%")
- ->orWhere('username', 'like', "%{$filter}%")
- ->orWhere('email', 'like', "%{$filter}%")
- ->paginate();
- $view = view('dashboard.usuario.user-list', $data)->render();
- return $view; // no frontend eu manipulo o HTML e troco pelo HTML renderizado na pesquisa, inclusive a paginação.
- }
- // Não tem pesquisa em ajax... código original
- $data = User::paginate();
- return view('dashboard.usuario.index', $data);
Add Comment
Please, Sign In to add comment