当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::get方法代码示例

本文整理汇总了PHP中Illuminate\Http\Request::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::get方法的具体用法?PHP Request::get怎么用?PHP Request::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Http\Request的用法示例。


在下文中一共展示了Request::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: search

 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;
 }
开发者ID:inoplate,项目名称:inoplate,代码行数:7,代码来源:CountryController.php

示例2: getDislike

 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();
     }
 }
开发者ID:stels-cs,项目名称:tinder-olega,代码行数:25,代码来源:User.php

示例3: index

 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);
 }
开发者ID:huudo,项目名称:bds1,代码行数:7,代码来源:LangController.php

示例4: login

 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();
     }
 }
开发者ID:emmendoza1986,项目名称:past_projects,代码行数:25,代码来源:SiteController.php

示例5: getSearch

 /**
  * 搜索
  *
  * @param Request $request
  * @author yangyifan <yangyifanphp@gmail.com>
  */
 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']]);
 }
开发者ID:nlls1990,项目名称:laravel-admin,代码行数:33,代码来源:SiteController.php

示例6: checklogin

 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('验证码不正确');
     }
 }
开发者ID:honxin,项目名称:studentclub,代码行数:34,代码来源:LogController.php

示例7: grid

 /**
  * 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);
 }
开发者ID:matheusgomes17,项目名称:berrier,代码行数:31,代码来源:UserSettingController.php

示例8: login

 /**
  * 用户通过邮箱和密码进行登录操作
  *
  * @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);
 }
开发者ID:diandianxiyu,项目名称:LaravelApi,代码行数:34,代码来源:UserController.php

示例9: getIndex

 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);
 }
开发者ID:Gadurp1,项目名称:Final-420-Project,代码行数:32,代码来源:TemplateController.php

示例10: handle

 /**
  * 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);
 }
开发者ID:jocoonopa,项目名称:lubri,代码行数:14,代码来源:ReportMiddleware.php

示例11: store

 /**
  * 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);
 }
开发者ID:shairozan,项目名称:oSPITE,代码行数:35,代码来源:SearchController.php

示例12: update

 /**
  * 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]);
 }
开发者ID:martinsv,项目名称:timegrid,代码行数:13,代码来源:BusinessServiceController.php

示例13: index

 /**
  * 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);
 }
开发者ID:NemanjaK,项目名称:meteoalarm,代码行数:40,代码来源:QualityController.php

示例14: getEvents

 /**
  * @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);
 }
开发者ID:Tampere,项目名称:Thingsee-API,代码行数:40,代码来源:ThingseeController.php

示例15: store

 /**
  * 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' => 'ไฟล์อัพโหลดมีปัญหากรุณาลองใหม่อีกครั้ง']);
         }
     }
 }
开发者ID:nettanawat,项目名称:Sfu-laravel,代码行数:40,代码来源:AnnounceController.php


注:本文中的Illuminate\Http\Request::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。