當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Requests\Request類代碼示例

本文整理匯總了PHP中App\Http\Requests\Request的典型用法代碼示例。如果您正苦於以下問題:PHP Request類的具體用法?PHP Request怎麽用?PHP Request使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Request類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: update

 /**
  * Just passes everything into the update. If there's a stricter
  * requirement,
  *
  * @param Request $request
  * @param $id
  * @return mixed
  */
 public function update(Request $request, $id)
 {
     if ($this->repository->find($id)) {
         return $this->repository->update($id, $request->all());
     }
     return null;
 }
開發者ID:keithyw,項目名稱:jackhammer,代碼行數:15,代碼來源:CoreCrud.php

示例2: update

 /**
  * updates activity sector
  * @param                      $id
  * @param Request              $request
  * @param SectorRequestManager $sectorRequestManager
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update($id, Request $request, SectorRequestManager $sectorRequestManager)
 {
     $activityData = $this->activityManager->getActivityData($id);
     if (Gate::denies('ownership', $activityData)) {
         return redirect()->back()->withResponse($this->getNoPrivilegesMessage());
     }
     $this->authorizeByRequestType($activityData, 'sector');
     $sectors = $request->all();
     foreach ($sectors['sector'] as &$sector) {
         if ($sector['sector_vocabulary'] == 1 || $sector['sector_vocabulary'] == '') {
             $sector['sector_vocabulary'] = 1;
             $sector['sector_category_code'] = '';
             $sector['sector_text'] = '';
         } elseif ($sector['sector_vocabulary'] == 2) {
             $sector['sector_code'] = '';
             $sector['sector_text'] = '';
         } else {
             $sector['sector_code'] = '';
             $sector['sector_category_code'] = '';
         }
     }
     if ($this->sectorManager->update($sectors, $activityData)) {
         $this->activityManager->resetActivityWorkflow($id);
         $response = ['type' => 'success', 'code' => ['updated', ['name' => 'Sector']]];
         return redirect()->to(sprintf('/activity/%s', $id))->withResponse($response);
     }
     $response = ['type' => 'danger', 'code' => ['update_failed', ['name' => 'Sector']]];
     return redirect()->back()->withInput()->withResponse($response);
 }
開發者ID:younginnovations,項目名稱:aidstream,代碼行數:36,代碼來源:SectorController.php

示例3: updatePost

 /**
  * Update post
  * @param  Request $request 
  * @param  int  $id      
  * @return void
  */
 public function updatePost(Request $request, $id)
 {
     DB::beginTransaction();
     try {
         $post = Post::findOrFail($id);
         $oldImage = "";
         $inputs = $request->all();
         if ($request->hasFile('images')) {
             $oldImage = public_path() . config('model.posts.path_folder_photo_post') . $post->images;
             $imageFile = $request->file('images');
             $inputs['images'] = $this->__storeImagePost($imageFile);
         } else {
             unset($inputs['images']);
         }
         if ($inputs['type'] == 2) {
             $this->__changeStickyPost($id);
         }
         $post->fill($inputs);
         $post->save();
         if (strlen($oldImage) != 0) {
             if (File::exists($oldImage)) {
                 File::delete($oldImage);
             }
         }
     } catch (Exception $e) {
         DB::rollback();
         throw new Exception("Error Processing Request", 1);
     }
     DB::commit();
 }
開發者ID:doankhoi,項目名稱:Application,代碼行數:36,代碼來源:PostRepository.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Validator $validator, Request $request)
 {
     $messages = $validator->errors();
     $request->session()->flash('status', 'Task was successful!');
     foreach ($messages->all() as $message) {
         print_r($message);
     }
     exit;
 }
開發者ID:system3d,項目名稱:consultas-tecnicas,代碼行數:14,代碼來源:UserController.php

示例5: mailOrder

 public function mailOrder(Request $request)
 {
     $view = 'emails.order';
     $subject = 'New Order Receipt';
     $data = $request->only('product_name', 'message_text', 'email', 'phone');
     $data['title'] = "New Order Email";
     $user = (object) ['email' => 'info@dakrush-ent.com'];
     return $this->sendTo($user, $subject, $view, $data);
 }
開發者ID:shegun-babs,項目名稱:dakrush,代碼行數:9,代碼來源:OrderMailer.php

示例6: storeOrUpdate

 public function storeOrUpdate(Request $request, $id = null)
 {
     $user = $id ? $this->getById($id) : new User();
     $user->name = $request->input('name');
     $user->email = $request->input('email');
     $user->password = Hash::make($request->input('password'));
     $user->status = UserStatus::ACTIVATED();
     $user->save();
     return $user;
 }
開發者ID:jaytyrrell13,項目名稱:jaytyrrell.co,代碼行數:10,代碼來源:EloquentUsersRepository.php

示例7: storeOrUpdate

 /**
  * If a post exists, update its properties. If not then create new
  * 
  * @param  Request $request 
  * @param  string  $id
  * @return \Illuminate\Database\Eloquent\Model
  */
 public function storeOrUpdate(Request $request, $id = null)
 {
     $post = $id ? $this->getById($id) : new Post();
     $post->user_id = Auth::id();
     $post->title = $request->input('title');
     $post->body = $request->input('body');
     $post->excerpt = $request->input('excerpt');
     $post->uri = str_slug($request->input('title'));
     $post->status = PostStatus::PUBLISHED();
     $post->save();
     return $post;
 }
開發者ID:jaytyrrell13,項目名稱:jaytyrrell.co,代碼行數:19,代碼來源:EloquentPostsRepository.php

示例8: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int                                $organizationId
  * @param CreateOrgReportingOrgRequestManager $createOrgReportingOrgRequestManager
  * @param Request                             $request
  * @return Response
  */
 public function update($organizationId, CreateOrgReportingOrgRequestManager $createOrgReportingOrgRequestManager, Request $request)
 {
     $organization = $this->organizationManager->getOrganization($organizationId);
     if (Gate::denies('belongsToOrganization', $organization)) {
         return redirect()->route('activity.index')->withResponse($this->getNoPrivilegesMessage());
     }
     $this->authorize('edit_activity', $organization);
     $input = $request->all();
     $this->orgReportingOrgManager->update($input, $organization);
     $this->organizationManager->resetStatus($organizationId);
     $response = ['type' => 'success', 'code' => ['updated', ['name' => 'Reporting Organization']]];
     return redirect()->route("organization.show", $organizationId)->withResponse($response);
 }
開發者ID:younginnovations,項目名稱:aidstream,代碼行數:21,代碼來源:OrgReportingOrgController.php

示例9: loadRequest

 public function loadRequest(Request $request)
 {
     $class = get_called_class();
     $class = explode('\\', $class);
     $class = end($class);
     $prefix = $class . '_';
     $arr_res = $request->all();
     foreach ($arr_res as $key => $value) {
         if (preg_match("/{$prefix}(?<name>.*)/", $key, $match)) {
             $name = $match['name'];
             $this->{$name} = $value;
         }
     }
 }
開發者ID:trongtri0705,項目名稱:staff,代碼行數:14,代碼來源:ActiveModel.php

示例10: rules

 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     if (Request::has('data')) {
         return ['data' => 'required'];
     }
     return ['judul_berita' => 'required', 'kategori_berita' => 'required', 'isi' => 'required', 'foto' => 'required'];
 }
開發者ID:brutalcrozt,項目名稱:SI-Sekolah-L5,代碼行數:12,代碼來源:BeritaRequest.php

示例11: update

 /**
  * updates activity title
  * @param                     $id
  * @param Request             $request
  * @param TitleRequestManager $titleRequestManager
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update($id, Request $request, TitleRequestManager $titleRequestManager)
 {
     if (!$this->currentUserIsAuthorizedForActivity($id)) {
         return redirect()->back()->withResponse($this->getNoPrivilegesMessage());
     }
     $activityData = $this->titleManager->getActivityData($id);
     $this->authorizeByRequestType($activityData, 'title');
     $activityTitle = $request->all();
     if ($this->titleManager->update($activityTitle, $activityData)) {
         $this->activityManager->resetActivityWorkflow($id);
         $response = ['type' => 'success', 'code' => ['updated', ['name' => 'Activity Title']]];
         return redirect()->to(sprintf('/activity/%s', $id))->withResponse($response);
     }
     $response = ['type' => 'danger', 'code' => ['update_failed', ['name' => 'Activity Title']]];
     return redirect()->back()->withInput()->withResponse($response);
 }
開發者ID:younginnovations,項目名稱:aidstream,代碼行數:23,代碼來源:TitleController.php

示例12: getPaginatedEntries

 /**
  * Returns the entries for the current page for this view.
  *
  * @return \Illuminate\Pagination\LengthAwarePaginator paginator containing the entries for the page, sorted/ordered or not.
  */
 public function getPaginatedEntries()
 {
     // Gets all the entries, sensitive to whether we're sorting for this request.
     $allEntries = $this->getEntriesSortable();
     $page = Paginator::resolveCurrentPage('page');
     // Returns the number of entries perpage, defined by Model#getPerPage
     $perPage = $allEntries->first()->getPerPage();
     // If the page number is beyond the number of pages, get it back to the last page.
     while (($page - 1) * $perPage > count($allEntries)) {
         $page -= 1;
     }
     // Return the subset of the entries for this page
     $entriesForPage = $allEntries->splice(($page - 1) * $perPage, $perPage);
     // Return the paginator for this subset.
     $entriesPaginator = new LengthAwarePaginator($entriesForPage, $this->getEntries()->first()->toBase()->getCountForPagination(), $perPage, $page, ['path' => Paginator::resolveCurrentPath(), 'pageName' => 'page']);
     // If we're ordering, append that to the links
     if ($this->getSortOrder()) {
         $entriesPaginator->appends(['order' => Request::get('order')]);
     }
     // If we're sorting, append that to the links
     if ($this->isSorting()) {
         $entriesPaginator->appends(['sort' => $this->getSortKey()]);
     }
     return $entriesPaginator;
 }
開發者ID:uidaho,項目名稱:squireproject,代碼行數:30,代碼來源:PaginatedRequest.php

示例13: rules

 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     if (Request::segment(3) == 'create') {
         $this->rules['file_name'] .= '|required';
     }
     return $this->rules;
 }
開發者ID:alexmon1989,項目名稱:kadsgroup,代碼行數:12,代碼來源:StoreCertificatesRequest.php

示例14: update

 /**
  * @param                      $id
  * @param Request              $request
  * @param BudgetRequestManager $budgetRequestManager
  * @return mixed
  */
 public function update($id, Request $request, BudgetRequestManager $budgetRequestManager)
 {
     $activityData = $this->activityManager->getActivityData($id);
     if (Gate::denies('ownership', $activityData)) {
         return redirect()->back()->withResponse($this->getNoPrivilegesMessage());
     }
     $this->authorizeByRequestType($activityData, 'budget');
     $budget = $request->all();
     if ($this->budgetManager->update($budget, $activityData)) {
         $this->activityManager->resetActivityWorkflow($id);
         $response = ['type' => 'success', 'code' => ['updated', ['name' => 'Budget']]];
         return redirect()->to(sprintf('/activity/%s', $id))->withResponse($response);
     }
     $response = ['type' => 'danger', 'code' => ['update_failed', ['name' => 'Budget']]];
     return redirect()->back()->withInput()->withResponse($response);
 }
開發者ID:younginnovations,項目名稱:aidstream,代碼行數:22,代碼來源:BudgetController.php

示例15: rules

 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $tipo_documento_valor = Request::get('per_dcmto_tipo');
     $doc_numero = 'required';
     $per_dcmto_tipo = 'required';
     $per_ruc = 'sometimes';
     if (Request::get('per_tipo') == '0002') {
         $per_ruc = 'required';
     }
     if ($tipo_documento_valor == '0001') {
         $doc_numero = 'required|numeric|digits:8|unique:persona,per_dcmto_numero';
     } else {
         if ($tipo_documento_valor == '0002') {
             $doc_numero = 'required|max:12';
         } else {
             if ($tipo_documento_valor == '0003') {
                 $doc_numero = 'required|numeric|digits:11';
             } else {
                 if ($tipo_documento_valor == '0006' || $tipo_documento_valor == '0004' || $tipo_documento_valor == '0005') {
                     $doc_numero = 'required|max:12';
                 }
             }
         }
     }
     if (Request::get('per_nacion') == '0002') {
         $per_dcmto_tipo = 'required|same:0002';
     }
     return ['per_tipo' => 'required', 'per_nacion' => 'sometimes|required', 'per_dcmto_tipo' => 'sometimes|' . $per_dcmto_tipo, 'per_dcmto_numero' => 'sometimes|' . $doc_numero, 'per_ape_paterno' => 'sometimes|required', 'per_ape_materno' => 'sometimes|required', 'per_nombre1' => 'sometimes|required', 'per_nombre2' => 'sometimes|sometimes', 'per_razon_social' => 'sometimes|required', 'per_ruc' => $per_ruc, 'per_direccion' => 'required', 'per_ubg_id' => 'required|numeric', 'per_direc_referencia' => 'required'];
 }
開發者ID:OscarSith,項目名稱:notaria-web,代碼行數:34,代碼來源:PersonaRequest.php


注:本文中的App\Http\Requests\Request類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。