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


PHP Request::all方法代码示例

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


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

示例1: record

 public function record()
 {
     if (\Request::hasFile('image') && \Request::file('image')->isValid() && \Auth::user()->suspend == false) {
         $file = \Request::file('image');
         $input = \Request::all();
         $date = new \DateTime();
         if (isset($input['anon'])) {
             $name = 'anon';
         } else {
             $name = \Auth::user()->name;
         }
         $validator = \Validator::make(array('image' => $file, 'category' => $input['category'], 'title' => $input['title'], 'caption' => $input['caption']), array('image' => 'required|max:1200|mimes:jpeg,jpg,gif', 'category' => 'required', 'title' => 'required|max:120', 'caption' => 'required|max:360'));
         if ($validator->fails()) {
             return redirect('/publish')->withErrors($validator);
         } else {
             $unique = str_random(10);
             $fileName = $unique;
             $destinationPath = 'database/pictures/stream_' . $input['category'] . '/';
             \Request::file('image')->move($destinationPath, $fileName);
             \DB::insert('insert into public.moderation (p_cat, p_ouser, p_title, p_caption, p_imgurl, p_status, p_reported, p_rating, created_at, updated_at) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [$input['category'], $name, $input['title'], $input['caption'], $unique, 'available', 0, 0, $date, $date]);
             $messages = 'Your content has been succesfully submitted. Going on moderation process.';
             return redirect('/system/notification')->with('messages', $messages);
         }
     } else {
         $messages = 'Your content data is invalid. The process is aborted.';
         return redirect('/system/notification')->with('messages', $messages);
     }
 }
开发者ID:chandrairawan,项目名称:nosproject,代码行数:28,代码来源:PublicationController.php

示例2: process

 public function process(Request $request)
 {
     // Ajax-validation is only possible, if the _formID was submitted (automatically done by the FormBuilder).
     if (\Request::has('_formID')) {
         // The FormBuilder should have saved the requestObject this form uses inside the session.
         // We check, if it is there, and can continue only, if it is.
         $sessionKeyForRequestObject = 'htmlBuilder.formBuilder.requestObjects.' . \Request::input('_formID');
         if (Session::has($sessionKeyForRequestObject)) {
             // Normally we assume a successful submission and return just an empty JSON-array.
             $returnCode = 200;
             $return = [];
             // We instantiate the requestObject.
             $formRequest = FormBuilderTools::getRequestObject(Session::get($sessionKeyForRequestObject));
             // We instantiate a controller with the submitted request-data
             // and the rules and messages from the requestObject.
             $validator = Validator::make(\Request::all(), $formRequest->rules(), $formRequest->messages());
             // Perform validation, extract error-messages for all fields on failure, put them inside a $return['errors']-array, and return status code 422.
             if ($validator->fails()) {
                 $errors = [];
                 foreach (array_dot(\Request::all()) as $fieldName => $fieldValue) {
                     $fieldErrors = FormBuilderTools::extractErrorsForField($fieldName, $validator->errors()->getMessages(), \Request::all());
                     if (count($fieldErrors) > 0) {
                         $errors[FormBuilderTools::convertArrayFieldDotNotation2HtmlName($fieldName)] = $fieldErrors;
                     }
                 }
                 $return['errors'] = $errors;
                 $returnCode = 422;
             }
             return new JsonResponse($return, $returnCode);
         }
     }
 }
开发者ID:nic-at,项目名称:htmlbuilder,代码行数:32,代码来源:AjaxValidationController.php

示例3: login

 public function login()
 {
     if (\Request::all()) {
         $validator = \Validator::make(\Request::all(), ['email' => 'required|email', 'password' => 'required']);
         if ($validator->fails()) {
             return \Redirect::to('/administrator')->withErrors($validator)->withInput();
         } else {
             $email = \Request::get('email');
             $password = \Request::get('password');
             $user = \User::whereEmail($email)->first();
             if ($user) {
                 if (\Hash::check($password, $user->password)) {
                     //Если нужна еще роль то тут добавить условие с ролью
                     if (\Auth::attempt(['email' => $email, 'password' => $password, 'role' => '1']) or \Auth::attempt(['email' => $email, 'password' => $password, 'role' => '2'])) {
                         return \Redirect::route('dashboard');
                     } else {
                         return \Redirect::route('administrator');
                     }
                 } else {
                     $errors['password'] = "Неверный пароль";
                     return \Redirect::route('administrator')->withInput()->withErrors($errors);
                 }
             } else {
                 $errors['email'] = "Данный адрес не зарегестрирован";
                 return \Redirect::route('administrator')->withInput()->withErrors($errors);
             }
             return view('abadmin::login');
         }
     }
     return view('abadmin::login');
 }
开发者ID:hramose,项目名称:admin,代码行数:31,代码来源:LoginController.php

示例4: short

 public function short()
 {
     $request = \Request::all();
     $target = ['url' => $request['url']];
     $rules = ['url' => 'required|url'];
     $message = ['url' => '请输入合法的链接地址', 'required' => '链接地址不能为空'];
     $validation = \Validator::make($target, $rules, $message);
     if ($validation->fails()) {
         $errmes = $validation->errors()->toArray();
         //组装json
         $info = json_encode(['code' => 0, 'message' => $errmes['url'][0]]);
         return $info;
     } else {
         //进一步处理
         //判断当前url在数据库中是否存在
         $record = Urls::where('url', $request['url'])->first();
         if (!empty($record)) {
             //组装json
             $shorturl = $record->short;
             $info = json_encode(['code' => '1', 'message' => 'http://www.url.dev/' . $shorturl]);
             return $info;
         } else {
             //生成短链并插入数据库
             $short = Urls::get_unique_short_url();
             $insert = Urls::insert(['url' => $request['url'], 'short' => $short]);
             if ($insert) {
                 $info = json_encode(['code' => 1, 'message' => 'http://www.url.dev/' . $short]);
                 return $info;
             } else {
                 $info = json_encode(['code' => 0, 'message' => '生成失败,请重试']);
                 return $info;
             }
         }
     }
 }
开发者ID:lnmput,项目名称:url,代码行数:35,代码来源:HomeController.php

示例5: streamRecord

 public function streamRecord()
 {
     $input = \Request::all();
     $date = new \DateTime();
     $name = \Auth::user()->name;
     $validator = \Validator::make(array('favor' => $input['favor'], 'comment' => $input['comment']), array('favor' => 'required|max:100', 'comment' => 'required|max:1000'));
     if ($validator->fails()) {
         return redirect('/stream/detail/' . $input['p_id'] . '/' . $input['p_cat'])->withErrors($validator);
     } else {
         $results = \DB::select('select avatar from users_data where name = ?', [$name]);
         foreach ($results as $result) {
             $avatar = $result->avatar;
         }
         \DB::insert('insert into comment.comment_' . $input['p_id'] . ' (c_ouser, c_favor, c_comment, avatar, created_at, updated_at) values (?, ?, ?, ?, ?, ?)', [$name, $input['favor'], $input['comment'], $avatar, $date, $date]);
         \DB::update('update stream.stream_' . $input['p_cat'] . ' set p_rating = (p_rating + 1) where p_id =?', [$input['p_id']]);
         // Insert notification system
         $n_message = 'Your publication is commented by ' . $name;
         $n_link = '/stream/detail/' . $input['p_id'] . '/' . $input['p_cat'];
         if ($input['p_ouser'] != 'anon' && $input['p_ouser'] != $name) {
             \DB::insert('insert into notification.inbox_' . $input['p_ouser'] . ' (n_message, n_link, n_sender, n_read, created_at, updated_at) values (?, ?, ?, ?, ?, ?)', [$n_message, $n_link, $name, false, $date, $date]);
         }
         $messages = 'You comment is successfully submitted.';
         return redirect('/stream/detail/' . $input['p_id'] . '/' . $input['p_cat'])->with('messages', $messages);
     }
 }
开发者ID:chandrairawan,项目名称:nosproject,代码行数:25,代码来源:HomeController.php

示例6: registerRoutes

 public static function registerRoutes()
 {
     Route::post('upload/' . static::$route, ['as' => 'admin.upload.' . static::$route, function () {
         $validator = Validator::make(\Request::all(), static::uploadValidationRules());
         if ($validator->fails()) {
             return Response::make($validator->errors()->get('file'), 400);
         }
         $file = \Request::file('file');
         $upload_path = config('admin.filemanagerDirectory') . \Request::input('path');
         $orginalFilename = str_slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME));
         $filename = $orginalFilename . '.' . $file->getClientOriginalExtension();
         $fullpath = public_path($upload_path);
         if (!\File::isDirectory($fullpath)) {
             \File::makeDirectory($fullpath, 0755, true);
         }
         if ($oldFilename = \Request::input('filename')) {
             \File::delete($oldFilename);
         }
         if (\File::exists($fullpath . '/' . $filename)) {
             $filename = str_slug($orginalFilename . '-' . time()) . '.' . $file->getClientOriginalExtension();
         }
         $filepath = $upload_path . '/' . $filename;
         $file->move($fullpath, $filename);
         return ['url' => asset($filepath), 'value' => $filepath];
     }]);
     Route::post('upload/delete/' . static::$route, ['as' => 'admin.upload.delete.' . static::$route, function () {
         if ($filename = \Request::input('filename')) {
             \File::delete($filename);
             return "Success";
         }
         return null;
     }]);
 }
开发者ID:pseudoagentur,项目名称:soa-sentinel,代码行数:33,代码来源:Image.php

示例7: request

 public static function request()
 {
     // Haetaan kaikki tilaukset tietokannasta
     $requests = Request::all();
     // Renderöidään tiedosto tilaus.html muuttujan $requests datalla
     View::make('request.html', array('requests' => $requests));
 }
开发者ID:hegemonni,项目名称:Tsoha-Bootstrap,代码行数:7,代码来源:requests_controller.php

示例8: postEdit

 public function postEdit($user)
 {
     $all_input = \Request::all();
     $edit_rules = array('first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email');
     $validator = \Validator::make($all_input, $edit_rules);
     if ($validator->passes()) {
         // save old password
         $old_password = $user->password;
         // update with all input
         $user->update($all_input);
         //restore old pw
         $user->password = $old_password;
         // set name alias
         $user->name = $all_input['first_name'] . ' ' . $all_input['last_name'];
         // set password only if posted
         if (isset($all_input['password']) && !empty($all_input['password'])) {
             $user->password = \Hash::make($all_input['password']);
         }
         // reset confirmation
         if (isset($all_input['confirmed'])) {
             $user->confirmed = 1;
             $user->confirmation_code = "";
         } else {
             $user->confirmed = 0;
         }
         $user->update();
         error_log("U " . json_encode($user));
         error_log("I " . json_encode($all_input));
         return redirect("/admin/users/{$user->id}/update");
     } else {
         return redirect("/admin/users/{$user->id}/update")->withErrors($validator);
     }
 }
开发者ID:strikles,项目名称:php,代码行数:33,代码来源:AdminUsersController.php

示例9: setParameters

 /**
  * Get all of the input and files for the request and store them in params.
  *
  */
 public function setParameters()
 {
     $this->params = \Request::all();
     if (!isset($this->params['content'])) {
         $this->params['content'] = file_get_contents("php://input");
     }
 }
开发者ID:jesposito,项目名称:learninglocker,代码行数:11,代码来源:BaseController.php

示例10: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $data = \Request::all();
     $data['user_id'] = \Auth::user()->id;
     $result = \App\Model\Comment::create($data);
     return back()->with('name', 'comment');
 }
开发者ID:kpaxer,项目名称:shcms,代码行数:12,代码来源:CommentController.php

示例11: _setConditions

 private function _setConditions()
 {
     extract(\Request::all());
     if (empty($fro_date) && empty($to_date) || $fro_date == 'all' && $to_date == 'all') {
         $to_date = date("Ym");
         $fro_date = $this->_dateNMonthsBack();
     }
     $conds = [];
     $conds['$and'][] = ['year_month' => ['$gte' => (int) $fro_date]];
     $conds['$and'][] = ['year_month' => ['$lte' => (int) $to_date]];
     if (!empty($districts) && $districts != '[]') {
         $conds['$and'][] = ['district_id' => ['$in' => json_decode($districts)]];
     }
     if (!empty($hubs) && $hubs != '[]') {
         $conds['$and'][] = ['hub_id' => ['$in' => json_decode($hubs)]];
     }
     if (!empty($age_ids) && $age_ids != '[]') {
         $conds['$and'][] = ['age_group_id' => ['$in' => json_decode($age_ids)]];
     }
     if (!empty($genders) && $genders != '[]') {
         $conds['$and'][] = ['gender' => ['$in' => json_decode($genders)]];
     }
     //if(!empty($regimens)&&$regimens!='[]') $conds['$and'][]=[ 'regimen_group_id'=>  ['$in'=> json_decode($regimens)] ];
     if (!empty($regimens) && $regimens != '[]') {
         $conds['$and'][] = ['regimen' => ['$in' => json_decode($regimens)]];
     }
     if (!empty($lines) && $lines != '[]') {
         $conds['$and'][] = ['regimen_line' => ['$in' => json_decode($lines)]];
     }
     if (!empty($indications) && $indications != '[]') {
         $conds['$and'][] = ['treatment_indication_id' => ['$in' => json_decode($indications)]];
     }
     //print_r($conds);
     return $conds;
 }
开发者ID:CHAIUganda,项目名称:vl_dashboard,代码行数:35,代码来源:DashboardController.php

示例12: update

 /**
  * @param $id
  * @return mixed
  */
 public function update($id)
 {
     $input = \Request::all();
     $units = Unit::findOrFail($id);
     $units->update($input);
     return \Response::json(['success' => true, 'message' => 'Unit Updated.', 'data' => $units]);
 }
开发者ID:bgaeddert,项目名称:PropMan,代码行数:11,代码来源:UnitController.php

示例13: handler

 public static function handler()
 {
     $data = array('success' => false, 'title' => trans('t.contactErrorTitle'), 'message' => trans('t.contactErrorMessage'));
     $requestAllowed = true;
     if (self::$requestType == 'ajax') {
         $requestAllowed = \Request::ajax() && \Request::get('getIgnore_isAjax');
     }
     if ($requestAllowed) {
         $validator = \Validator::make(\Request::all(), self::$rules);
         if ($validator->fails()) {
             $messages = $validator->getMessageBag()->toArray();
             $finalMessages = array();
             foreach ($messages as $field => $fieldMessages) {
                 foreach ($fieldMessages as $fieldMessage) {
                     $finalMessages[] = $fieldMessage;
                 }
             }
             $message = implode("\n", $finalMessages);
             $data['message'] = $message;
             return self::returnData($data);
         } else {
             try {
                 Mailer::sendMessage(\Request::all());
                 $data['success'] = true;
                 $data['title'] = trans('t.contactSuccessTitle');
                 $data['message'] = trans('t.contactSuccessMessage');
             } catch (\Exception $e) {
                 Dbar::error("Error while sending message: " . $e->getMessage());
             }
         }
         return self::returnData($data);
     }
     \App::abort(404);
 }
开发者ID:gtcrais,项目名称:gtcms,代码行数:34,代码来源:ContactController.php

示例14: update

 /**
  * @param $id
  * @return mixed
  */
 public function update($id)
 {
     $input = \Request::all();
     $property = Property::findOrFail($id);
     $property->update($input);
     return \Response::json(['success' => true, 'message' => 'Owner Updated.', 'data' => $property]);
 }
开发者ID:bgaeddert,项目名称:PropMan,代码行数:11,代码来源:PropertyController.php

示例15: postEdit

 public function postEdit($group)
 {
     $all_input = \Request::all();
     $group->update($all_input);
     //return $this->getEdit($group);
     return redirect("/admin/groups/{$group->id}/update");
 }
开发者ID:strikles,项目名称:php,代码行数:7,代码来源:AdminGroupsController.php


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