private function my_query(Request $request, array $fields) { $query = Role::query(); foreach ($fields as $field) { if ($request->has($field)) { if ($field == 'id' || $field == 'status') { $query->where($field, '=', trim($request->{$field})); } else { $query->where($field, 'like', '%' . trim($request->{$field}) . '%'); } } } return $query->orderBy('id', 'desc'); }
/** * Display a listing of the resource. * * @author WN * @return \Illuminate\View\View */ public function index() { return $this->standardIndexAction(Role::query(), 'role.index', 'roles'); }