input() публичный статический метод

Retrieve an input item from the request.
public static input ( string $key = null, string | array | null $default = null ) : string | array
$key string
$default string | array | null
Результат string | array
Пример #1
0
 /**
  * Save data.
  *
  * @param Request $request Request
  * @param Int     $user_id User id
  *
  * @return int
  */
 public function saveData($request, $user_id = '')
 {
     $password = '';
     $role_id = $request->input('role_id');
     if ($user_id) {
         $user = self::find($user_id);
         //Dectach
         $user->roles()->detach();
         $password = $user->password;
     } else {
         // Check duplicate
         $email = $request->input('email');
         $check_user = self::where('email', '=', $email)->first();
         if ($check_user) {
             return false;
         } else {
             $user = new self();
         }
     }
     $new_password = bcrypt($request->input('password'));
     if (!$new_password) {
         $new_password = $password;
     }
     $user->name = $request->input('name');
     $user->email = $request->input('email');
     $user->password = $new_password;
     $results = $user->save();
     if ($results) {
         $user->roles()->attach($role_id);
         return $user->id;
     } else {
         return $results;
     }
 }
Пример #2
0
 public function postBatch($act = 'update')
 {
     $result = false;
     switch ($act) {
         case 'delete':
             $ids = \Request::input('ids');
             $idsArr = explode(',', $ids);
             $result = FeedBack::whereIn('id', $idsArr)->delete();
             break;
         case 'update':
             $key = \Request::input('key');
             $val = \Request::input('value');
             $key = $key == '_status' ? 'status' : '';
             if (!empty($key)) {
                 $ids = \Request::input('ids');
                 $idsArr = explode(',', $ids);
                 $result = FeedBack::whereIn('id', $idsArr)->update([$key => $val]);
             }
             break;
     }
     $msg = [];
     if ($result) {
         $msg['status'] = 'success';
     } else {
         $msg['status'] = 'failed';
     }
     return response(json_encode($msg))->header('Content-Type', 'application/json');
 }
Пример #3
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;
     }]);
 }
Пример #4
0
 /**
  * Funcao usada pelo ajax para buscar o relatorio informando o nome da action
  * 
  * @return json Relatorio formatado para o Google Charts
  */
 public function getGet(ReportLogic $r)
 {
     // Busca o nome do relatorio
     // $report_namespace = $this;
     $report_request = \Request::input('report');
     // Atribui um rows vazio
     $rows = array();
     // Verifica se é mesmo um report request!
     if (substr($report_request, 0, 6) === 'report' && method_exists($this, $report_request)) {
         $rows = $this->{$report_request}();
     } else {
         // Joga uma exception caso nao exista!
         abort(405, 'Inexistente!');
     }
     // Comeca o tratamento do array de configuracoes do Google Charts
     $arrConfig = [];
     // Adiciona as linhas no Logic
     $r->setBody($rows);
     // Montador de colunas
     $arrConfig['cols'] = $r->getHeadersFormat('js');
     // Montador de linhas
     $arrConfig['rows'] = $r->getBodyFormat('js');
     // Retorna o array para o laravel, que ira retornar o json
     return $arrConfig;
 }
Пример #5
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $unit
  * @return Response
  */
 public function update(Printer $printer)
 {
     $printer->fill(\Request::input())->save();
     //        $printer->authors()->detach();
     //        $printer->authors()->attach( $request->input('authors_id') );
     return redirect('printers');
 }
Пример #6
0
 /**
  * 设置工作流步骤的关联人员
  * 
  * @return string
  */
 public function relation($data)
 {
     $this->setCurrentAction('step', 'relation', 'workflow')->checkPermission();
     $url = R('common', $this->module . '.' . $this->class . '.' . $this->function, ['stepid' => $data['id'], 'workflow_id' => \Request::input('id')]);
     $html = $this->hasPermission ? '<a class="step-relation" target="_blank" href="' . $url . '"><i class="fa fa-user"></i></a>' : '<i class="fa fa-user" style="color:#ccc"></i>';
     return $html;
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if ($body = \Request::input('body')) {
         $translation = Translation::where('body', $body)->first();
         if ($translation) {
             $response = response()->json([['id' => $translation->getId(), 'body' => $translation->body]]);
         } else {
             $response = response()->json(['errors' => ['The translation hasn\'t found.']], 404);
         }
     } else {
         if ($autocomplete = \Request::input('autocomplete')) {
             $translations = Translation::select('body')->where('body', 'LIKE', "{$autocomplete}%")->take(\Request::header('Limit') ?: 5)->get();
             if (count($translations) > 0) {
                 $response = response()->json($translations);
             } else {
                 $response = response()->json(['errors' => ['The matched translations haven\'t found.']], 404);
             }
         } else {
             $result = Translation::paginate(\Request::header('Limit') ?: 10);
             $headers['Current-Page'] = $result->currentPage();
             $headers['Last-Page'] = $result->lastPage();
             $translations = [];
             foreach ($result as $key => $item) {
                 $translations[$key]['id'] = $item->getId();
                 $translations[$key]['body'] = $item->body;
             }
             if (count($translations) > 0) {
                 $response = response()->json($translations, 200, $headers);
             } else {
                 $response = response()->json(['errors' => ['there aren\'t any translations.']], 404);
             }
         }
     }
     return $response;
 }
Пример #8
0
 public function update($id)
 {
     $user_id = \Request::input('user_id');
     $checkBorrowCount = BookUser::whereUser_idAndStatus($user_id, 'pinjam')->count();
     $checkOrderCount = BookUser::whereUser_idAndStatus($user_id, 'pesan')->count();
     $checkCount = $checkBorrowCount + $checkOrderCount;
     if ($checkCount < 5) {
         $check = BookUser::whereUser_idAndBook_idAndStatus($user_id, $id, 'pinjam')->count();
         if ($check < 1) {
             $book = Book::find($id);
             $book->stock -= 1;
             $book->save();
             $data = new BookUser();
             $data->user_id = $user_id;
             $data->book_id = $id;
             $data->status = 'pinjam';
             $data->save();
             return redirect('operator/transactions')->with('successMessage', 'Berhasil meminjam buku.');
         } else {
             return redirect('operator/borrow')->with('errorMessage', 'User hanya bisa meminjam 1 buku dengan judul yang sama.');
         }
     } else {
         return redirect('operator/borrow')->with('errorMessage', 'User Hanya bisa memesan/meminjam 5 buku');
     }
 }
 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);
         }
     }
 }
Пример #10
0
 function KisiSil()
 {
     \Auth::logout();
     \Session::flush();
     \DB::delete('delete from users WHERE name = ?', [\Request::input('isim')]);
     return \Redirect::to('auth/register');
 }
Пример #11
0
 public function postFinishedtask()
 {
     $reservedhour = \App\ReservedHours::find(\Request::input('hour_id'));
     \App\FinishedHour::create(array('user_id' => $reservedhour->user_id, 'service_id' => $reservedhour->service_id, 'client' => $reservedhour->client, 'price' => $reservedhour->service->price, 'created_at' => date('Y-m-d')));
     \DB::table('reservedhours')->where('id', '=', $reservedhour->id)->delete();
     return 'true';
 }
 /**
  * Display the password reset view for the given token.
  *
  * If no token is present, display the link request form.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  string|null  $token
  * @return \Illuminate\Http\Response
  */
 public function showResetForm(Request $request, $token = null)
 {
     $email = $request->input('email');
     if (view()->exists('auth.passwords.reset')) {
         return view('auth.passwords.reset')->with(compact('token', 'email'));
     }
     return view('auth.reset')->with('token', $token);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $permisos = \App\Permisos::find($id);
     $permisos->id_opcion = \Request::input('opcion');
     $permisos->UserLevelID = \Request::input('nivel_usuario');
     $permisos->save();
     return redirect('permisos');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $nivel = \App\UserLevel::find($id);
     $nivel->UserLevelID = \Request::input('nivel_usuario');
     $nivel->UserLevelName = \Request::input('nombre_nivel');
     $nivel->save();
     return redirect('niveles')->with('message', 'Se ha actualizado el registro');
 }
Пример #15
0
 /**
  * Funcao para edicao da traducao do [Modulo]
  * @param string $controller Nome do controlador
  * @return void
  */
 public function getIndex($controller = false)
 {
     $lang = \Request::input('lang');
     if (!$lang) {
         $lang = \App::getLocale();
     }
     return view('cinimod::admin.generator.trans')->with(['langlist' => $this->_getLangPacks(), 'langlist_sel' => $lang, 'langfiles' => $this->_getTransFiles($lang)]);
 }
Пример #16
0
 public function validator(array $data)
 {
     \Validator::extend('passcheck', function () {
         $value = \Request::input('old_password');
         return \Hash::check($value, \Auth::user()->password);
     });
     return \Validator::make($data, ['password' => 'required|confirmed|min:6', 'old_password' => 'required|passcheck'], ['old_password.required' => 'Паролата е задължителна.', 'old_password.passcheck' => 'Грешна парола.', 'password.required' => 'Паролата е задължителна.', 'password.confirmed' => 'Потвърдената парола е грешна.', 'password.min' => 'Минимална дължина на паролата 6 символа.']);
 }
Пример #17
0
 /**
  * 设置工作流步骤的关联人员
  * 
  * @return string
  */
 public function relation($data)
 {
     $this->setCurrentAction('step', 'relation', 'workflow')->checkPermission();
     $url = route($this->module . '.' . $this->class . '.' . $this->function, ['stepid' => $data['id'], 'workflow_id' => \Request::input('id')]);
     $html = $this->hasPermission ? '<a title="设置关联人员" class="step-relation" href="' . $url . '"><i class="icon-user"></i></a>' : '';
     $html = ['show' => $this->hasPermission, 'html' => $html];
     return $html;
 }
Пример #18
0
 public function update(EditUserRequest $request, $id)
 {
     $user = \JLcourier\Entities\User::find($id);
     $user->name = \Request::input('name');
     $user->email = \Request::input('email');
     $user->save();
     return redirect()->route('user.edit', ['user' => $id])->with('message', 'El usuario ha sido actualizado.');
 }
 public function post_contact()
 {
     $info_array = ['from' => \Request::input("email"), 'from_name' => "User At Contact page", 'to' => social('admin_email'), 'to_name' => "Ahmed Badawy", 'subject' => "Msg From Contact Page in: " . base_url, "msg" => \Request::input('msg')];
     //		dd("hello");
     $this->send_msg($info_array);
     return \Redirect::back()->with('s-msg', 'Message Was Sent');
     // $response = \Event::fire(new \App\Events\testEvent());
 }
Пример #20
0
 /**
  * Save data.
  *
  * @param Request $request Request
  * @param ID      $role_id ID
  *
  * @return ID
  */
 public function saveData($request, $role_id)
 {
     if ($role_id) {
         $roles = self::find($role_id);
     } else {
         $roles = new self();
     }
     $roles->role_title = $request->input('role_title');
     $roles->role_slug = $request->input('role_title') ? str_slug($request->input('role_title')) : '';
     $roles->description = $request->input('description');
     $results = $roles->save();
     if (!$results) {
         return $results;
     } else {
         return $roles->id;
     }
 }
Пример #21
0
 public function deleteIndex()
 {
     // Delete user $id
     $id = \Request::input('user_id');
     $user = User::find($id);
     $user->groups()->sync([]);
     $user->delete();
     return redirect('/admin/users');
 }
Пример #22
0
 /**
  * Reset the given user's password.
  *
  * @param  Request  $request
  * @return Response
  */
 public function postDefine(Request $request)
 {
     $v = \Validator::make($request->all(), ['email' => 'required|email', 'password' => 'required|different:old_password|min:6', 'old_password' => 'required'], ['password.different' => 'Le champ nouveau mot de passe doit être différent du mot de passe actuel']);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors());
     }
     $email = $request->input('email');
     $password = $request->input('password');
     $old_password = $request->input('old_password');
     if (\Auth::attempt(['email' => $email, 'password' => $old_password])) {
         $user = \Auth::user();
         $user->password = bcrypt($password);
         $user->save();
         \Auth::login($user);
         return redirect('user')->with(['status' => 'success', 'message' => 'Votre mot de passe a bien été changé']);
     }
     return redirect()->back()->with(['status' => 'danger', 'message' => 'Les identifiants email / mot de passe ne correspondent pas'])->withInput($request->only('email'));
 }
Пример #23
0
 public function destroy(Page $page)
 {
     if (\Request::has('id')) {
         Page::destroy(\Request::input('id'));
         return ['result' => true];
     }
     $page->delete();
     return redirect('dash/page')->with('message', 'Page was delete success.');
 }
 public function lists($lang, $area)
 {
     global $data;
     global $settings;
     if (Request::exists('line-id')) {
         $result = $this->getStationList(Request::input('line-id'));
         return Response::json($result)->setCallback(Input::get('callback'));
     }
 }
Пример #25
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function getIndex()
 {
     $users = User::paginate(15);
     if (\Request::has('key')) {
         $key = \Request::input('key');
         $users = User::where('name', 'like', '%' . $key . '%')->paginate(15);
     }
     return view('admin.user.index', compact('users'));
 }
Пример #26
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $category = ItemsCategory::find($id);
     $category->name = \Request::input('name');
     $category->description = \Request::input('description');
     $category->save();
     \Session::flash('message', 'Категория успешно обновлена.');
     return redirect()->back();
 }
Пример #27
0
 public function authenticate(LoginRequest $request)
 {
     if (\Auth::attempt(['username' => \Request::input('username'), 'password' => \Request::input('password'), 'estado' => true])) {
         return redirect('administracion/productos');
     } else {
         \Session::flash('authenticate', 'El usuario o contraseña son inválidos.');
         return redirect('login');
     }
 }
Пример #28
0
 public function access_2()
 {
     $date = new \DateTime();
     $read = false;
     $value = \Request::input('value');
     $client = \Request::input('client');
     \DB::insert('insert into public.arduino (v_val, v_cli, v_read, created_at, updated_at) values (?, ?, ?, ?, ?)', [$value, $client, $read, $date, $date]);
     return 'This is X553M Server, your value is: ' . $value . ', From client: ' . $client;
 }
Пример #29
0
 public function destroy(Post $post)
 {
     if (\Request::has('id')) {
         Post::destroy(\Request::input('id'));
         return ['result' => true];
     }
     $post->delete();
     return redirect('dash/post')->with('message', 'Post was delete success.');
 }
Пример #30
0
 public function postIndex()
 {
     $data = session()->get('lockscreen');
     $email = $data[0]['email'];
     $password = \Request::input('password');
     $validator = Validator::make(\Request::all(), ['password' => 'required']);
     $result = $this->result($email, $password, $validator);
     return $result;
 }