all() public static method

Get all of the input and files for the request.
public static all ( ) : array
return array
 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);
     }
 }
 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);
         }
     }
 }
Example #3
0
 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');
 }
Example #4
0
 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;
             }
         }
     }
 }
 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);
     }
 }
Example #6
0
 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;
     }]);
 }
 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));
 }
Example #8
0
 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);
     }
 }
 /**
  * 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");
     }
 }
Example #10
0
 /**
  * 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');
 }
 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;
 }
Example #12
0
 /**
  * @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]);
 }
Example #13
0
 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);
 }
Example #14
0
 /**
  * @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]);
 }
Example #15
0
 public function postEdit($group)
 {
     $all_input = \Request::all();
     $group->update($all_input);
     //return $this->getEdit($group);
     return redirect("/admin/groups/{$group->id}/update");
 }
Example #16
0
 /**
  * @param $id
  * @return mixed
  */
 public function update()
 {
     $input = \Request::all();
     $orgs = Org::findOrFail(\Auth::user()->org_id);
     $orgs->update($input);
     return \Response::json(['success' => true, 'message' => 'Org Updated.', 'data' => $orgs]);
 }
 /**
  * @return mixed
  */
 public function store()
 {
     $input = \Request::all();
     $transaction = new Transaction($input);
     $transaction = $transaction->save();
     return \Response::json(['success' => true, 'message' => 'Transaction Created.', 'data' => $transaction]);
 }
Example #18
0
 /**
  * Return specified element of Request.
  * Return all items of Request if empty parameter.
  *
  * @param null $ele
  *
  * @return array
  */
 function rq($ele = null)
 {
     if (!$ele) {
         return Request::all();
     }
     return Request::get($ele);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     //
     $room_type = new RoomType($request->all());
     $room_type->save();
     return $room_type;
 }
 public function editRecord()
 {
     $name = \Auth::user()->name;
     if (\Request::hasFile('avatar') && \Request::file('avatar')->isValid()) {
         $file = \Request::file('avatar');
         $input = \Request::all();
         $validator = \Validator::make(array('avatar' => $file, 'bio' => $input['bio']), array('avatar' => 'max:800|mimes:jpeg,jpg,gif', 'bio' => 'max:1000'));
         if ($validator->fails()) {
             return redirect('/profile/edit')->withErrors($validator);
         } else {
             if ($input['avatar_path'] == '0') {
                 $unique = str_random(20);
                 $fileName = $unique;
             } else {
                 $fileName = $input['avatar_path'];
             }
             $destinationPath = 'database/pictures/avatars/';
             \Request::file('avatar')->move($destinationPath, $fileName);
             \DB::table('users_data')->where('name', $name)->update(['bio' => $input['bio'], 'avatar' => $fileName]);
             return redirect('/profile/' . $name);
         }
     } else {
         $input = \Request::all();
         $validator = \Validator::make(array('bio' => $input['bio']), array('bio' => 'max:1000'));
         if ($validator->fails()) {
             return redirect('/profile/edit')->withErrors($validator);
         } else {
             \DB::table('users_data')->where('name', $name)->update(['bio' => $input['bio']]);
             return redirect('/profile/' . $name);
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = \Request::all();
     $passenger = new Passenger();
     $passenger->title = $input['passenger_title'];
     $passenger->name = $input['passenger_name'];
     $passenger->sex = $input['passenger_sex'];
     $passenger->age = $input['passenger_age'];
     $passenger->address_line_1 = $input['passenger_address1'];
     $passenger->address_line_2 = $input['passenger_address2'];
     $passenger->address_line_3 = $input['passenger_address3'];
     $passenger->state = $input['passenger_state'];
     $passenger->country = $input['passenger_country'];
     $passenger->occupation = $input['passenger_occupation'];
     $passenger->cabin_id = $input['cabin_form'];
     $passenger->save();
     $reservation = new Reservation();
     $reservation->cruise_id = $input['cruise_form'];
     $reservation->cabin_id = $input['cabin_form'];
     $reservation->customer_id = \Auth::User()->id;
     $reservation->save();
     $cabin = Cabin::where('id', $input['cabin_form'])->first();
     $cabin->occupied = false;
     $cabin->save();
     return view('pages.index')->with('title', 'Welcome');
 }
 /**
  * Validate request for current resource
  *
  * @param Request $request
  * @param array $rules
  * @param array $messages
  * @param array $customAttributes
  */
 public function validateRequestOrFail($request, array $rules, $messages = [], $customAttributes = [])
 {
     $validator = $this->getValidationFactory()->make($request->all(), $rules, $messages, $customAttributes);
     if ($validator->fails()) {
         Errors::throwHttpExceptionWithCode(Errors::VALIDATION_ERROR, $validator->errors()->getMessages());
     }
 }
 protected function termsAjaxHandler()
 {
     \Plugin::add_action('ajax_backend_get_taxonomy_terms', function () {
         $terms = $this->app->make(Repositories\TermTaxonomyRepository::class)->ajaxGetSelect2TaxonomyTerms(\Request::get('taxonomy'), \Request::get('term'), \Request::get('value'));
         return \Response::json($terms)->send();
     }, 0);
     \Plugin::add_action('ajax_backend_add_taxonomy_term', function () {
         $term = \Request::all();
         $response = [];
         if (count($term) > 1) {
             $termKeys = array_keys($term);
             $termValues = array_values($term);
             $taxName = str_replace('new', '', $termKeys[0]);
             $taxObj = $this->app->make('Taxonomy')->getTaxonomy($taxName);
             $termName = $termValues[0];
             $termParent = 0 != $termValues[1] ? (int) $termValues[1] : null;
             $postId = isset($termValues[2]) ? $termValues[2] : 0;
             $createdTerm = $this->app->make('Taxonomy')->createTerm($termName, $taxName, ['parent' => $termParent]);
             if ($createdTerm && !$createdTerm instanceof EtherError) {
                 $result['replaces'][$taxName . '_parent_select'] = View::make('backend::post.taxonomy-parent-select', ['taxName' => $taxName, 'taxObj' => $taxObj])->render();
                 $result['replaces'][$taxName . '_checklist'] = View::make('backend::post.taxonomy-checklist', ['taxName' => $taxName, 'postId' => $postId, 'taxObj' => $taxObj])->render();
                 $response['success'] = $result;
             } else {
                 $response['error'] = $response['error'] = $createdTerm->first();
             }
         } else {
             $response['error'] = 'Invalid Arguments Supplied';
         }
         return \Response::json($response)->send();
     }, 0);
 }
 public function loaded()
 {
     $camplog = new CampaignLog(['user' => ['session' => session('_token')], 'device' => ['mac' => "test mac xD"], 'interaction' => ['welcome' => new MongoDate()]]);
     $camplog->save();
     return \Request::all();
     //        return true;
 }
Example #25
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $input = \Request::all();
     $expense = new Expense($input);
     \Auth::user()->expenses()->save($expense);
     return redirect('home');
 }
Example #26
0
 public function __construct()
 {
     $this->api = new \App\Http\Middleware\CityadsApi();
     $this->request = \Request::all();
     if (empty($this->request['start'])) {
         $this->request['start'] = 0;
     }
 }
Example #27
0
 public function search()
 {
     $input = \Request::all();
     $s = $input['s'];
     $model = new \App\Model\Post();
     $posts = $model->where('title', 'like', "%{$s}%")->orWhere('content', 'like', "%{$s}%")->paginate(25)->appends($input);
     return view('post/list')->with('posts', $posts)->with('type', ['name' => 'search', 'title' => "搜索: \"{$s}\""]);
 }
Example #28
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $user = User::findOrFail($id);
     $user->fill(\Request::all());
     $user->full_name = $user->first_name . " " . $user->last_name;
     $user->save();
     return redirect()->route('admin.users.index');
 }
 public function update($proposalId)
 {
     $this->proposalValidator->validate(\Request::all(), $proposalId);
     $data = \Request::only('title', 'description', 'start_date', 'end_date');
     $this->proposalRepository->update($proposalId, $data);
     \Notification::success("Proposal updated");
     return \Redirect::route('proposals.index');
 }
Example #30
0
function request($get = false)
{
    if ($get) {
        return Request::get($get);
    } else {
        return Request::all();
    }
}