public function search(Request $request) { $search = $request->get('q'); $page = $request->get('page'); $results = Country::where('name', 'like', '%' . $search . '%')->take($page * 5)->simplePaginate(5); return $results; }
public function index(Request $request) { $orderby = empty(trim($request->get('orderby'))) ? 'id' : $request->get('orderby'); $order = empty(trim($request->get('order'))) ? 'asc' : $request->get('order'); $data = ['title' => 'Quản lý ngôn ngữ', 'items' => $items = $this->lang->getAll(['*'], null, $orderby, $order)]; return view('backend.language.index', $data); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(CookieJar $cookieJar, Request $request) { if ($request->isMethod('post')) { $supplier_email = $request->get('supplier_email'); $supplier_password = $request->get('supplier_password'); $checkAgentExists = Supplier::where("email", "=", $supplier_email); $checkAgentExists = $checkAgentExists->where("password", "=", md5($supplier_password . Config::get('constants.SITENAME'))); $checkAgentExists = $checkAgentExists->get(); if ($request->get('remember_login')) { $cookieJar->queue(Cookie::make('supplier_email', $supplier_email, 60)); $cookieJar->queue(Cookie::make('supplier_password', $supplier_password, 60)); } else { $cookieJar->queue(Cookie::forget('supplier_email')); $cookieJar->queue(Cookie::forget('supplier_password')); } if (count($checkAgentExists) > 0) { Session::put('SUPPLIER_ACCESS_ID', $checkAgentExists[0]->id); Session::put('SUPPLIER_ACCESS_FNAME', $checkAgentExists[0]->first_name); Session::put('SUPPLIER_ACCESS_LNAME', $checkAgentExists[0]->last_name); return redirect('supplier/dashboard'); } else { return Redirect::route('supplier_land')->with('message', ['Invalid email address or/and password.']); } } }
public function getDislike(Request $r) { try { $uid = $r->get('id', false); $filterId = $r->get('filter_id', false); if ($uid) { $mid = $this->getUser()->id; if ($filterId) { $filter = VKFilter::find($filterId); } $exits = DB::table('vk_like')->where('from_id', $mid)->where('to_id', $uid)->count(); if ($exits) { return response()->json(['id' => trans('main.already-like'), 'filter' => !empty($filter) ? $filter->getList($this->getUser()) : []], 422); } else { DB::table('vk_like')->insert(['from_id' => $mid, 'to_id' => $uid, 'type' => 0]); return response()->json(['ok' => 'ok', 'filter' => !empty($filter) ? $filter->getList($this->getUser()) : []]); } } else { return response()->json(['id' => trans('main.id-not-pass')]); } } catch (\Exception $e) { \Log::error($e->getMessage() . ' ' . $e->getFile() . ':' . $e->getLine()); return $e->getMessage() . ' file ' . $e->getFile() . ':' . $e->getLine(); } }
public function login(Request $request) { if (Auth::check() == false) { $id = $request->get('sjsu_id'); $password = $request->get('password'); $inputs = ['id' => $id, 'password' => $password]; $rules = ['id' => 'required', 'password' => 'required']; $validator = Validator::make($inputs, $rules); $user = User::find($id); if ($validator->fails()) { return redirect()->back()->withErrors($validator)->withInput($request->except('password')); } if ($user && $password === $user->password) { Auth::login($user); if ($id <= 38) { return redirect()->action('ProfessorsController@index'); } else { return redirect()->action('StudentsController@index'); } } return redirect()->back(); } else { return redirect()->back(); } }
/** * 搜索 * * @param Request $request * @author yangyifan <*****@*****.**> */ public function getSearch(Request $request) { //接受参数 $search = $request->get('search', ''); $sort = $request->get('sort', 'id'); $order = $request->get('order', 'asc'); $limit = $request->get('limit', 0); $offset = $request->get('offset', config('config.page_limit')); //解析params parse_str($search); //组合查询条件 $map = []; if (!empty($site_name)) { $map['site.site_name'] = ['like', '%' . $site_name . '%']; } if (!empty($email)) { $map['a.email'] = ['like', '%' . $email . '%']; } if (!empty($site_cat_id)) { $map['site.site_cat_id'] = $site_cat_id; } if (!empty($status)) { $map['article.status'] = $status; } $data = SiteModel::search($map, $sort, $order, $limit, $offset); echo json_encode(['total' => $data['count'], 'rows' => $data['data']]); }
public function checklogin(Request $request) { //print_r($request->all()); $name = $request->get('name'); $code = $request->get('code'); $password = $request->input('password'); if ($code == session('captcha')) { //$manager = \DB::table('managers')->select('name','password','status')->where('name','=',$name)->get(); $manager = Models\Manager::select('id', 'role_id', 'name', 'password', 'status')->where('name', '=', $name)->first(); if (count($manager) == 1) { if ($manager->status == 1) { if ($manager->password == md5(md5($password))) { session(array('adminid' => $manager->id, 'adminname' => $manager->name)); //获取当前角色拥有的权限并存入session $role = Models\Role::find($manager->role_id); $authAllows = array(); foreach ($role->auths as $v) { $authAllows[] = $v['module_name'] . '.' . $v['controller_name'] . '.' . $v['action_name']; } session(array('authAllows' => $authAllows)); return redirect(action('Admin\\IndexController@index')); } else { return $this->loginRedirectTo('账号密码错误'); } } else { return $this->loginRedirectTo('账号未激活'); } } else { return $this->loginRedirectTo('用户不存在'); } } else { return $this->loginRedirectTo('验证码不正确'); } }
/** * Return grid data * * @param $request \Illuminate\Http\Request * @return Response */ public function grid(Request $request) { $take = $request->has('rowCount') ? $request->get('rowCount') : 10; $skip = $request->get('current') - 1; $searchPhrase = $request->has('searchPhrase') ? $request->get('searchPhrase') : ''; $sort = $request->has('sort') ? $request->get('sort') : false; // $results = $this->page->search($searchPhrase); if ($searchPhrase) { $results = $this->setting->select('id', 'name', 'key', 'default', 'user_editable', 'created_at', 'updated_at')->where('name', 'like', '%' . $searchPhrase . '%')->orWhere('key', 'like', '%' . $searchPhrase . '%'); } else { $results = $this->setting->select('id', 'name', 'key', 'default', 'user_editable', 'created_at', 'updated_at'); } $count_results = $results->count(); $results = $results->take($take)->skip($take * $skip); if (is_array($sort)) { $results = $results->orderBy(key($sort), $sort[key($sort)]); } $results = $results->get(); $rows = []; foreach ($results as $row) { $rows[] = ['id' => $row->id, 'name' => $row->name, 'key' => $row->key, 'default' => $row->default, 'user_editable' => $row->user_editable]; } $data = array('current' => (int) $request->get('current'), 'rowCount' => $take, 'rows' => $rows, 'total' => $count_results); return response($data); }
/** * 用户通过邮箱和密码进行登录操作 * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function login(Request $request) { //获取当前访问的全部的地址 $request_url = str_replace("http://" . Config::get('app.url'), "", $request->url()); //验证参数 $validator = Validator::make($request->all(), ['email' => 'required|email', 'password' => 'required']); //验证参数完整性 if ($validator->fails()) { // var_dump($validator); $error = $validator->errors()->all(); //写入日志 Log::error(['error' => $error, 'request' => $request->all(), 'header' => $request->headers, 'client_ip' => $request->getClientIp()]); //返回错误信息 return Error::returnError($request_url, 1001); } $email = $request->get('email'); $password = $request->get('password'); //检查有没有 $user_model = User::checkUserLogin($email, $password); if ($user_model == false) { return Error::returnError($request_url, 2001); } //更新token $token = User::updateToken($user_model); //返回对应的结果 $json_arr = ['request' => $request_url, 'ret' => User::getUserInfo($user_model->id), 'token' => $token]; return Common::returnResult($json_arr); }
public function getIndex(Request $request) { $page = !is_null($request->get('show')) ? $request->get('show') : ''; switch ($page) { case 'typography': $tmp = 'core/template/Typography'; break; case 'icon-moon': $tmp = 'core/template/Iconmoon'; break; case 'forms': $tmp = 'core/template/Forms'; break; case 'tables': $tmp = 'core/template/Tables'; break; case 'panel': $tmp = 'core/template/Panel'; break; case 'grid': $tmp = 'core/template/Grid'; break; case 'icons': $tmp = 'core/template/Icons'; break; default: $tmp = 'core/template/Index'; break; } $this->data = array('pageTitle' => 'Templates', 'pageNote' => 'Elements for template', 'page' => $page); return view($tmp, $this->data); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (self::TOKEN !== $request->get('token') && ExportExcel::TOKEN !== $request->get('token')) { throw new \Exception('Token unvalid!'); } return $next($request); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { //Check for null name if (strlen($request->get('name')) == 0) { return []; } //Initiate searches and return object of results $searchable = ['App\\Person', 'App\\Character', 'App\\Weapon', 'App\\Item', 'App\\Time', 'App\\Place', 'App\\Faction']; foreach ($searchable as $object) { $components = explode('\\', $object); $className = strtolower($components[count($components) - 1]); $hits = $object::where('name', 'like', '%' . $request->get('name') . '%')->get(); //Lets supress the HTML laden notes foreach ($hits as $hit) { unset($hit->notes); //set the link for the object $model_components = explode("\\", get_class($hit)); $hitClass = strtolower($model_components[count($model_components) - 1]); if ($hitClass == 'person') { $action = 'people'; } else { $action = $className . 's'; } $hit->link = \URL::to($action . '/' . $hit->id); $results[] = $hit; } } return response()->json($results); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Business $business, Service $service, Request $request) { $this->log->info("BusinessServiceController: update: businessId:{$business->id} serviceId:{$service->id}"); $service->update(['name' => $request->get('name'), 'description' => $request->get('description'), 'prerequisites' => $request->get('prerequisites')]); Flash::success(trans('manager.business.service.msg.update.success')); return redirect()->route('manager.business.service.show', [$business, $service]); }
/** * Display the specified resource. * * @param \Illuminate\Http\Request $request * * @return \Illuminate\Http\Response * @internal param \Illuminate\Http\Request $request * @internal param int $id */ public function index(Request $request) { // Get lat / lng $lat = $request->get('lat', false); $lng = $request->get('lng', false); if (!$lat || !$lng) { return response()->json(['message' => 'Both latitude and longitude are required.'], Response::HTTP_BAD_REQUEST); } if (!is_numeric($lat) || !is_numeric($lng)) { return response()->json(['message' => 'Both latitude and longitude must be double values.'], Response::HTTP_BAD_REQUEST); } $stationRepository = StationRepository::getInstance(); $station = $stationRepository->getCaqiForLocation(doubleval($lat), doubleval($lng)); if (!empty($station)) { // Get measurements for components $componentsRepository = ComponentRepository::getInstance(); $measurementRepository = MeasurementRepository::getInstance(); $components = $componentsRepository->getAll(); $componentMeasurements = []; /** @var Component $component */ foreach ($components as $component) { // Get latest measurement! $measurement = $measurementRepository->getLatestForStationAndComponent($station, $component); $componentMeasurements[$component->getSepaId()]['measurement'] = $measurement; $componentMeasurements[$component->getSepaId()]['component'] = $component; } $responseData = ['station' => $station, 'components' => $componentMeasurements]; return response()->json($responseData); } return response()->json([], Response::HTTP_NO_CONTENT); }
/** * @param Illuminate\Http\Request $request * @param string $device * @return json events */ public function getEvents(Request $request, $device) { /** * Limit events * @var integer */ $limit = 10; /** * Start at timestamp * @var integer */ $start = 0; /** * End at string * @var string */ $end = ""; // Set query params based on request params if ($request->has('limit')) { $limit = $request->get('limit'); } if ($request->has('start')) { $start = $request->get('start'); } if ($request->has('end')) { $end = "&end=" . $request->get('end'); } try { $thingsee = new \Thingsee\ThingseeAPI(); } catch (\GuzzleHttp\Exception\ClientException $e) { dd($e); } // Return events in json return $thingsee->getEvents($device, "?senses=0x00060100,0x00060200,0x00060400,0x00060300&limit=" . $limit . "&start=" . $start . $end); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $validator = Validator::make($request->all(), ['file' => 'mimes:pdf', 'name' => 'max:100']); if ($validator->fails()) { return redirect()->back()->withErrors(['file' => 'ไฟล์จะต้องเป็น .pdf เท่านั้น'])->withInput(); } if (Input::file('file')->isValid()) { $filePath = date('Ymd_His') . '.pdf'; if (Input::file('file')->move(base_path() . '/public/uploads/Announces/Announce-' . $request->get('year'), $filePath)) { //example of delete exist file $announceList = Announce::all(); if (sizeof($announceList) != 0) { $lastAnnounce = $announceList[sizeof($announceList) - 1]; $filename = base_path() . '/public/uploads/Announces/Announce-/' . $request->get('year') . '/' . $lastAnnounce->file_path; if (File::exists($filename)) { File::delete($filename); } // $oldAnnounce = Announce::findOrNew($lastAnnounce->id); $lastAnnounce = DB::table('announces')->where('year', $request->get('year'))->first(); // dd($lastAnnounce);die; if ($lastAnnounce != null) { Announce::destroy($lastAnnounce->id); } } $announce = new Announce(); $announce->file_path = $filePath; $announce->year = $request->get('year'); $announce->save(); return redirect('/announces'); } else { return redirect()->back()->withErrors(['error_message' => 'ไฟล์อัพโหลดมีปัญหากรุณาลองใหม่อีกครั้ง']); } } }
public function pdf(Request $request) { //view for admin, agent and developer $providers = Provider::filter($request->get('name'), $request->get('contact'), $request->get('category')); $pdf = PDF::loadView('providers.pdf', compact('providers')); return $pdf->stream(); }
public function agendaJson(Request $request) { // load of actions between start and stop provided by calendar js if ($request->has('start') && $request->has('end')) { $actions = \App\Action::with('group')->where('start', '>', Carbon::parse($request->get('start')))->where('stop', '<', Carbon::parse($request->get('end')))->orderBy('start', 'asc')->get(); } else { $actions = \App\Action::with('group')->orderBy('start', 'asc')->get(); } $event = ''; $events = ''; foreach ($actions as $action) { $event['id'] = $action->id; $event['title'] = $action->name; $event['description'] = $action->body . ' <br/> ' . $action->location; $event['body'] = filter($action->body); $event['summary'] = summary($action->body); $event['location'] = $action->location; $event['start'] = $action->start->toIso8601String(); $event['end'] = $action->stop->toIso8601String(); $event['url'] = action('ActionController@show', [$action->group->id, $action->id]); $event['group_url'] = action('ActionController@index', [$action->group->id]); $event['group_name'] = $action->group->name; $event['color'] = $action->group->color(); $events[] = $event; } return $events; }
public function unlink(Module $module, Request $request, FileRepository $fileRepository, Imagy $imagy) { DB::table('media__imageables')->whereFileId($request->get('fileId'))->delete(); $file = $fileRepository->find($request->get('fileId')); $imagy->deleteAllFor($file); $fileRepository->destroy($file); }
public function update(Request $request, $id_usuario) { try { $usuario = User::find($id_usuario); if ($usuario && $usuario->estado == "activo") { $facultad = Facultad::find($request->get('id_facultad')); $programa = Programa::find($request->get('id_programa')); if ($facultad->estado == "activo") { if ($programa->estado == "activo") { $programa->id_facultad = $facultad->id_facultad; $programa->nombre_programa = $request->get('nombre_programa'); if ($programa->save()) { return response()->json(['error' => false, 'mensaje' => 'Datos actualizados exitosamente', 'programa' => $programa]); } } else { return response()->json(['error' => true, 'mensaje' => 'Error, el Programa que desea actualizar no existe']); } } else { return response()->json(['error' => true, 'mensaje' => 'Error, la facultad a la cual quiere asociar el programa no existe']); } } else { return response()->json(['error' => true, 'mensaje' => 'El usuario que desea hacer la petición no se encuentra Registrado']); } } catch (\Exception $e) { return response()->json(['error' => true, 'mensaje' => 'Error al verificar la existencia del Usuario que realiza la peticion', 'excepcion' => $e]); } }
public function store(Request $request) { if ($request->has('droplet_id')) { $droplet = $this->dropletRepository->getById($request->get('droplet_id')); } else { $droplet = $this->dropletRepository->getOrCreateByHash($request->get('upload_hash'), Auth::id()); } if ($file = $request->file('file')) { $file_name = $file->getClientOriginalName(); $filesystem = filesystem()->init($droplet->filesystem()); try { // Does the source folder exist if (!$filesystem->has($droplet->present()->directory)) { $filesystem->createDir($droplet->present()->directory); } $filesystem->write($droplet->present()->directory . '/' . $file_name, file_get_contents($file->getRealPath())); $this->fileRepository->create($droplet->id, $droplet->storage_id, $file_name, $file->getMimeType(), $file->getSize()); if ($request->ajax()) { return response()->json($droplet->id, 200); } } catch (\Exception $e) { die($e->getMessage()); } return redirect()->back(); } }
public function store($communityId, Request $request) { $hoursOpen = $request->get('hours_open'); $hoursClose = $request->get('hours_close'); $validator = new \App\RExpress\CommunityHours\CommunityHoursValidator($hoursOpen, $hoursClose); if ($validator->fails()) { return $validator->response()->json(); } $communityHours = Community\CommunityHour::where('community_id', '=', $communityId)->first(); if (is_null($communityHours)) { $communityHours = new Community\CommunityHour(); $communityHours->community_id = $communityId; } $communityHours->mon_open = $hoursOpen[0]; $communityHours->tue_open = $hoursOpen[1]; $communityHours->wed_open = $hoursOpen[2]; $communityHours->thu_open = $hoursOpen[3]; $communityHours->fri_open = $hoursOpen[4]; $communityHours->sat_open = $hoursOpen[5]; $communityHours->sun_open = $hoursOpen[6]; // closed $communityHours->mon_close = $hoursClose[0]; $communityHours->tue_close = $hoursClose[1]; $communityHours->wed_close = $hoursClose[2]; $communityHours->thu_close = $hoursClose[3]; $communityHours->fri_close = $hoursClose[4]; $communityHours->sat_close = $hoursClose[5]; $communityHours->sun_close = $hoursClose[6]; $communityHours->save(); $response = new GenericResponse(); return $response->json(); }
public function main(Request $request) { switch ($request->data) { case "courses": $courses = Course::all(); foreach ($courses as $course) { $course["status"] = $course->seatsStatus(); $course["enrolled"] = $course->totalEnrolled(); $course["waitlist"] = $course->totalWaitlisted(); } return response()->json(['courses' => $courses]); case "gpa": if ($request->has('student_id')) { $student = User::find($request->get('student_id')); return $student->gpa(); } else { return []; } case "classestaken": return Auth::user()->pastClasses(); case "activecodes": $section_id = $request->get('section_id'); return Auth::user()->returnActiveCodes($section_id); case "generateaddcode": $section_id = $request->get('section_id'); Auth::user()->generateAddCode($section_id); return redirect()->action('CoursesController@addCode'); default: return "no data specified"; } }
public function postContact(Request $request) { $formData = ['sender_name_surname' => $request->get('sender_name_surname'), 'sender_email' => $request->get('sender_email'), 'sender_phone_number' => $request->get('sender_phone_number'), 'subject' => $request->get('subject'), 'post' => $request->get('message')]; $rules = ['sender_name_surname' => 'required', 'sender_email' => 'required|email', 'sender_phone_number' => 'required', 'subject' => 'required', 'post' => 'required']; $validation = Validator::make($formData, $rules); if ($validation->fails()) { return Redirect::action('FormPostController@getContact')->withErrors($validation)->withInput(); } /* Mail::send('emails.contact-form.form', $formData, function ($message) { $message->from($request->get('sender_email'), $request->get('sender_name_surname')); $message->to('*****@*****.**', 'Lorem Lipsum')->subject($request->get('subject')); }); */ /* $mailer = new Mailer; $mailer->send('emails.contact-form.form', '*****@*****.**', $request->get('subject'), $formData); */ $formPost = new FormPost(); $formPost->sender_name_surname = $formData['sender_name_surname']; $formPost->sender_email = $formData['sender_email']; $formPost->sender_phone_number = $formData['sender_phone_number']; $formPost->subject = $formData['subject']; $formPost->message = $formData['post']; $formPost->lang = getLang(); $formPost->save(); return Redirect::action('FormPostController@getContact')->with('message', 'Success'); }
/** * getPartialName. * * @method getPartialName * * @return string */ public function getPartialName($chunkPath) { $originalName = $this->getOriginalName(); $extension = $this->getExtension($originalName); $token = $this->request->get('token'); return $chunkPath . md5($originalName . $token) . $extension . '.part'; }
public function update($id, Request $request) { $template = DnsTemplate::findOrFail($id); $template->name = $request->get('name'); $template->description = $request->get('description'); $template->update(); $rrs = $request->get('rrfields'); if (is_array($rrs)) { foreach ($rrs as $rr_input) { if (array_key_exists('delete', $rr_input) && strcmp($rr_input['delete'], 'true') === 0) { $rr = DnsTemplateRr::findOrFail($rr_input['id']); $rr->delete(); } else { if (array_key_exists('id', $rr_input)) { $rr = DnsTemplateRr::findOrFail($rr_input['id']); $rr->fill($rr_input); $rr->dns_template_id = $template->id; $rr->update(); } else { $rr = new DnsTemplateRr(); $rr->fill($rr_input); $rr->dns_template_id = $template->id; $rr->save(); } } } } return $this->show($id); }
/** * Obtain the user information from Google. * * @param Request $request * @return Socialite ->user() */ public function handleGoogleProviderCallback(Request $request) { if ($request->get('error') == "access_denied") { return redirect('/'); } $authorizationCode = $request->get('code'); $googleTokens = Tokens::getGoogleTokens($authorizationCode); //return var_dump($googleTokens); $user = Socialite::driver('google')->getUserByToken($googleTokens->access_token); $email = $user['emails'][0]['value']; $name = $user['name']['givenName'] . " " . $user['name']['familyName']; $avatar = $user['image']['url']; if (!GoogleUser::existsByEmailAndId($email, Auth::user()->id) && isset($googleTokens->refresh_token)) { GoogleUser::create(['user_id' => Auth::user()->id, 'email' => $email, 'names' => $name, 'avatar' => $avatar, 'googleAccessToken' => $googleTokens->access_token, 'googleRefreshToken' => $googleTokens->refresh_token, 'uriCode' => $authorizationCode, 'expireValue' => $googleTokens->expires_in]); return redirect('/availability/google')->with(['message' => 'You have linked this profile (' . $email . ')']); } elseif (GoogleUser::existsByEmailAndId($email, Auth::user()->id) && isset($googleTokens->refresh_token)) { $id = GoogleUser::where('email', '=', $email)->where('user_id', '=', Auth::user()->id)->select('id')->first()->pluck('id')['id']; GoogleUser::updateTokens($id, ['googleAccessToken' => $googleTokens->access_token, 'googleRefreshToken' => $googleTokens->refresh_token, 'uriCode' => $authorizationCode, 'expireValue' => $googleTokens->expires_in]); return redirect('/availability/google')->with(['message' => 'You already have this profile (' . $email . '). Data is updated.']); } elseif (GoogleUser::existsByEmailAndId($email, Auth::user()->id) && !isset($googleTokens->refresh_token)) { return redirect('/availability/google')->with(['message' => 'You already have this profile (' . $email . ')']); } elseif (!GoogleUser::existsByEmailAndId($email, Auth::user()->id) && !isset($googleTokens->refresh_token)) { return redirect('/availability/google')->withErrors(['Missing refresh token. Contact the administrator.']); } else { return var_dump($authorizationCode, $googleTokens, $user); abort(500, "Auth error. Contact the admin"); } return redirect('/availability/google'); }
public function ajaxLoad(Request $request) { if ($request->get('id')) { return Tax::where('active', 1)->where('id', $request->get('id'))->first(); } return Tax::where('active', 1)->get(); }
public function index(Request $request) { $type = $request->get('type'); $q = $request->get('q'); $search = new Search(); return ['type' => $type, 'items' => $search->search($q, $type)]; }
/** * 搜索 * * @param Request $request */ public function getSearch(Request $request) { //接受参数 $search = $request->get('search', ''); $sort = $request->get('sort', 'id'); $order = $request->get('order', 'asc'); $limit = $request->get('limit', 0); $offset = $request->get('offset', config('config.page_limit')); //解析params parse_str($search); //组合查询条件 $map = []; if (!empty($user_name)) { $map['user_name'] = ['like', '%' . $user_name . '%']; } if (!empty($email)) { $map['email'] = ['like', '%' . $email . '%']; } if (!empty($mobile)) { $map['mobile'] = ['like', '%' . $mobile . '%']; } if (!empty($status)) { $map['status'] = $status; } if (!empty($sex)) { $map['sex'] = $sex; } if (!empty($birthday)) { $map['birthday'] = $birthday; } $data = UserInfoModel::search($map, $sort, $order, $limit, $offset); echo json_encode(['total' => $data['count'], 'rows' => $data['data']]); }