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


PHP Request::isMethod方法代碼示例

本文整理匯總了PHP中Illuminate\Http\Request::isMethod方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::isMethod方法的具體用法?PHP Request::isMethod怎麽用?PHP Request::isMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Http\Request的用法示例。


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

示例1: news

 public function news(Request $request)
 {
     if ($request->isMethod('POST')) {
         //            News::create($request->except('_token'));
         // read image from temporary file
         $file = $request->file('imagePrev');
         $img = Image::make($file->getRealPath());
         $nameFile = $file->getClientOriginalName();
         //          resize image
         $img->fit(263, 263);
         // save image
         $img->save("images/" . $nameFile);
         News::create(['text' => $request->input('editor1'), 'header' => $request->input('header'), 'picture' => "images/" . $nameFile]);
         //            switch ( $request->input('type') ) {
         //                case 'insert':
         //                    News::create($request->except('_token'));
         //                    break;
         //                case 'update':
         //                    News::find( $request->input('id') )->update([
         //                        'header' => $request->input('header'),
         //                        'text' => $request->input('editor1'),
         //                    ]);
         //                    break;
         //            }
     }
     if ($request->isMethod('GET')) {
         $item = News::find($request->input('remove'));
         if ($item) {
             $item->delete();
         }
     }
     $news = News::orderBy('created_at', 'DESC')->paginate(15);
     return view('admin/news', ['news' => $news]);
 }
開發者ID:GraninNikita,項目名稱:feo,代碼行數:34,代碼來源:AdminController.php

示例2: update

 /**
  * @param Request $request
  * this is the function where update the shopping cart and mainly consider about the change the quantity and display the total amount
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function update(Request $request)
 {
     if ($request->isMethod('post')) {
         if ($request->get('UpdateCart')) {
             $data = $request->session()->get('items');
             $request->session()->pull('items');
             foreach ($data as $item) {
                 $quantity = $request->get($item['id'] . 'quantity');
                 $request->session()->push('items', ['id' => $item['id'], 'quantity' => $quantity, 'name' => $item['name'], 'price' => $item['price'], 'imgpath' => $item['imgpath']]);
             }
             $data = $request->session()->get('items');
             $cat_name = $request->get('catName');
             return view('pages.cart.cart', compact('data', 'cart', 'total', 'n', 'cat_name'));
         }
     }
     //this is the remove item from shoiing cart
     if ($request->isMethod('post')) {
         if ($request->get('cartDestroy')) {
             $data = $request->session()->get('items');
             $item_id = $request->get('cartDestroy');
             //first pull product details from the session array
             $request->session()->pull('items');
             foreach ($data as $item) {
                 if ($item['id'] != $item_id) {
                     $request->session()->push('items', ['id' => $item['id'], 'quantity' => $item['quantity'], 'name' => $item['name'], 'price' => $item['price'], 'imgpath' => $item['imgpath']]);
                 }
             }
             $data = $request->session()->get('items');
             $cat_name = $request->get('catName');
             return view('pages.cart.cart', compact('data', 'cat_name'));
         }
     }
 }
開發者ID:Legolas000,項目名稱:PaintBuddy,代碼行數:38,代碼來源:CartHandle.php

示例3: anyUpload

 public function anyUpload(InterfaceFileStorage $userFileStorage, AmqpWrapper $amqpWrapper, Server $server, UploadEntity $uploadEntity)
 {
     /* @var \App\Components\UserFileStorage $userFileStorage */
     $responseVariables = ['uploadStatus' => false, 'storageErrors' => [], 'uploadEntities' => []];
     if ($this->request->isMethod('post') && $this->request->hasFile('file') && $this->request->file('file')->isValid()) {
         $tmpDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tmp-user-files-to-storage' . DIRECTORY_SEPARATOR;
         $tmpFilePath = $tmpDir . $this->request->file('file')->getClientOriginalName();
         $this->request->file('file')->move($tmpDir, $this->request->file('file')->getClientOriginalName());
         $userFileStorage->setValidationRules($this->config->get('storage.userfile.validation'));
         $newStorageFile = $userFileStorage->addFile($tmpFilePath);
         if ($newStorageFile && !$userFileStorage->hasErrors()) {
             /* @var \SplFileInfo $newStorageFile */
             // AMQP send $newfile, to servers
             foreach ($server->all() as $server) {
                 if (count($server->configs) > 0) {
                     foreach ($server->configs as $config) {
                         // Send server and file info to upload queue task
                         $amqpWrapper->sendMessage($this->config->get('amqp.queues.uploader.upload'), json_encode(['file' => $newStorageFile->getRealPath(), 'url' => $server->scheme . '://' . $config->auth . '@' . $server->host . '/' . trim($config->path, '\\/')]));
                     }
                 } else {
                     // The server has no configuration
                     $amqpWrapper->sendMessage($this->config->get('amqp.queues.uploader.upload'), json_encode(['file' => $newStorageFile->getRealPath(), 'url' => $server->scheme . '://' . $server->host]));
                 }
             }
             $responseVariables['uploadStatus'] = true;
         } else {
             $responseVariables['storageErrors'] = $userFileStorage->getErrors();
         }
         if ($this->request->ajax()) {
             return $this->response->json($responseVariables);
         }
     }
     $responseVariables['uploadEntities'] = $uploadEntity->limit(self::UPLOAD_ENTITIES_LIMIT)->orderBy('created_at', 'DESC')->get();
     return $this->view->make('upload.index', $responseVariables);
 }
開發者ID:ysaroka,項目名稱:uploader,代碼行數:35,代碼來源:UploadController.php

示例4: execute

 /**
  * {@inheritdoc}
  */
 public function execute($request)
 {
     /** @var $request ObtainCreditCard */
     if (false == $this->supports($request)) {
         throw RequestNotSupportedException::createActionNotSupported($this, $request);
     }
     if ($this->request->isMethod('POST')) {
         $creditCard = new CreditCard();
         $creditCard->setHolder($this->request->get('card_holder'));
         $creditCard->setNumber($this->request->get('card_number'));
         $creditCard->setSecurityCode($this->request->get('card_cvv'));
         $creditCard->setExpireAt(new DateTime($this->request->get('card_expire_at')));
         $request->set($creditCard);
         return;
     }
     $form = $this->viewFactory->make($this->templateName, ['model' => $request->getModel(), 'firstModel' => $request->getFirstModel(), 'actionUrl' => $request->getToken() ? $request->getToken()->getTargetUrl() : null]);
     throw new HttpResponse(new Response($form->render(), 200, ['Cache-Control' => 'no-store, no-cache, max-age=0, post-check=0, pre-check=0', 'X-Status-Code' => 200, 'Pragma' => 'no-cache']));
     /*
         $content = $this->viewFactory->make($this->templateName, [
             'model'      => $request->getModel(),
             'firstModel' => $request->getFirstModel(),
             'form'       => $form->render(),
             'actionUrl'  => $request->getToken() ? $request->getToken()->getTargetUrl() : null,
         ]);
     
         $this->gateway->execute($renderTemplate);
     
         throw new HttpResponse(new Response($renderTemplate->getResult(), 200, [
             'Cache-Control' => 'no-store, no-cache, max-age=0, post-check=0, pre-check=0',
             'X-Status-Code' => 200,
             'Pragma'        => 'no-cache',
         ]));
     */
 }
開發者ID:recca0120,項目名稱:laravel-payum,代碼行數:37,代碼來源:ObtainCreditCardAction.php

示例5: contact

 /**
  * Create simple contact form
  * @return void
  */
 public function contact(Request $request)
 {
     if ($request->isMethod('get')) {
         return view('pages.contact');
     } elseif ($request->isMethod('post')) {
         dd($request->all());
     }
 }
開發者ID:maherelgamil,項目名稱:ketabat,代碼行數:12,代碼來源:PagesController.php

示例6: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->isMethod('POST') || $request->isMethod('PUT')) {
         json_decode($request->getContent());
         if (json_last_error() != JSON_ERROR_NONE) {
             return response()->json("Request must be json", 400);
         }
     }
     return $next($request);
 }
開發者ID:generationtux,項目名稱:json-middleware,代碼行數:17,代碼來源:ValidateIsJsonMiddleware.php

示例7: correctSlug

 /**
  * @param \Illuminate\Http\Request $request
  */
 protected function correctSlug(&$request)
 {
     $slug = $request->input('slug');
     $validateMethod = $request->isMethod('POST') || $request->isMethod('PUT') || $request->isMethod('PATCH');
     if (!empty($slug) && $validateMethod) {
         $strSlug = Str::slug($slug);
         if ($strSlug !== $slug) {
             $request->request->set('slug', $strSlug);
         }
     }
 }
開發者ID:garbleapp,項目名稱:garble,代碼行數:14,代碼來源:CorrectTextSlug.php

示例8: update

 public function update(Request $request, $id)
 {
     if ($request->isMethod('get')) {
         $data['item'] = Bahan::find($id);
         return view('update', $data);
     } elseif ($request->isMethod('post')) {
         $item = Bahan::find($id);
         $item->nama = Input::get('nama');
         $item->kode = Input::get('kode');
         $item->save();
         return redirect('bahan');
     }
 }
開發者ID:freyandhy,項目名稱:belajar-laravel5,代碼行數:13,代碼來源:BahanController.php

示例9: rules

 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules(\Illuminate\Http\Request $request)
 {
     // validation rule for create request.
     if ($request->isMethod('POST')) {
         return ['name' => 'required', 'content' => 'required'];
     }
     // Validation rule for update request.
     if ($request->isMethod('PUT') || $request->isMethod('PATCH')) {
         return ['name' => 'required'];
     }
     // Default validation rule.
     return [];
 }
開發者ID:Jastkast,項目名稱:Page,代碼行數:18,代碼來源:PageAdminRequest.php

示例10: rules

 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules(Request $request)
 {
     if ($request->isMethod('POST')) {
         // validation rule for create request.
         return [];
     }
     if ($request->isMethod('PUT') || $request->isMethod('PATCH')) {
         // Validation rule for update request.
         return [];
     }
     // Default validation rule.
     return [];
 }
開發者ID:litecms,項目名稱:block,代碼行數:18,代碼來源:BlockAdminRequest.php

示例11: rules

 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules(\Illuminate\Http\Request $request)
 {
     $user = $this->route('user');
     // validation rule for create request.
     if ($request->isMethod('POST')) {
         return ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|min:6'];
     }
     // Validation rule for update request.
     if ($request->isMethod('PUT') || $request->isMethod('PATCH')) {
         return ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users,email,' . $user->id];
     }
     // Default validation rule.
     return [];
 }
開發者ID:litepie,項目名稱:user,代碼行數:19,代碼來源:UserAdminRequest.php

示例12: rules

 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules(\Illuminate\Http\Request $request)
 {
     $role = $this->route('role');
     // validation rule for create request.
     if ($request->isMethod('POST')) {
         return ['name' => 'required|max:50|unique:roles'];
     }
     // Validation rule for update request.
     if ($request->isMethod('PUT') || $request->isMethod('PATCH')) {
         return [];
     }
     // Default validation rule.
     return [];
 }
開發者ID:LavaLite,項目名稱:framework,代碼行數:19,代碼來源:RoleAdminWebRequest.php

示例13: update

 public function update(Request $request, $id)
 {
     if ($request->isMethod('get')) {
         $data['item'] = Resep::find($id);
         $data['kokis'] = Koki::all();
         return view('resep.update', $data);
     } elseif ($request->isMethod('post')) {
         $item = Resep::find($id);
         $item->nama = Input::get('nama');
         $item->kode = Input::get('kode');
         $item->koki_id = Input::get('koki_id');
         $item->save();
         return redirect('resep');
     }
 }
開發者ID:freyandhy,項目名稱:belajar-laravel5,代碼行數:15,代碼來源:ResepController.php

示例14: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     //
     //Log::info('$request=<' . $request . '>');
     if ($request->isMethod('post')) {
         $bodyContent = $request->getContent();
         //Log::info('$bodyContent=<' . $bodyContent . '>');
         $bodyJson = json_decode($bodyContent);
         $keyPath = $this->keyRoot_ . $bodyJson->token . '/pubKey.pem';
         $fp = fopen($keyPath, 'r');
         $pubKeyMem = fread($fp, 8192);
         fclose($fp);
         $pubkeyid = openssl_pkey_get_public($pubKeyMem);
         $token = $bodyJson->token;
         $sign = $bodyJson->sign;
         $ok = openssl_verify($token, hex2bin($sign), $pubkeyid, "sha256");
         openssl_free_key($pubkeyid);
         if ($ok == 1) {
             $profilePath = $this->keyRoot_ . $bodyJson->token . '/profile';
             //Log::info('$bodyJson->payload=<' . json_encode($bodyJson->payload) . '>');
             file_put_contents($profilePath, json_encode($bodyJson->payload));
             return response()->json(['status' => 'success']);
         } else {
             return response()->json(['status' => 'failure']);
         }
     }
 }
開發者ID:WatorVapor,項目名稱:account,代碼行數:33,代碼來源:ProfileController.php

示例15: reportsAction

 public function reportsAction(Request $request)
 {
     $users = DB::select('select id, first_name, last_name, email from users');
     if ($request->isMethod('post')) {
         $id = substr($request->input('email'), strpos($request->input('email'), ":") + 2);
         $year = $request->input('year');
         $month = $request->input('month');
         $events = DB::select('select users.first_name, events.*, transport.name as t_name, transport.load_consumption,
               transport.moving_consumption, transport.stat_consumption
               from users inner join events on users.id = events.user_id
               left join transport on events.vehicle_id = transport.id
               where year(events.date) = ? and month(events.date) = ?
               AND users.id = ?', [$year, $month, $id]);
         $calc = [];
         foreach ($events as $event) {
             $parsed_arrive = date_parse($event->client_arrive);
             $parsed_leave = date_parse($event->client_leave);
             $hours['arrive'] = $parsed_arrive['hour'] + $parsed_arrive['minute'] / 60;
             $hours['leave'] = $parsed_leave['hour'] + $parsed_leave['minute'] / 60;
             $hours['actual'] = $hours['leave'] - $hours['arrive'] - $event->min_spent / 60;
             $calc[$event->id]['distance'] = (int) $event->spidometer_finish - (int) $event->spidometer_start;
             $calc[$event->id]['fuel'] = $calc[$event->id]['distance'] / 100 * $event->moving_consumption + $event->min_spent / 60 * $event->load_consumption + $hours['actual'] * $event->stat_consumption;
         }
         //        die(var_dump($calc));
         return view('admin/reports', ['events' => $events, 'calc' => $calc, 'users' => $users]);
     }
     return view('admin/reports', ['users' => $users]);
 }
開發者ID:einorler,項目名稱:laravel-test,代碼行數:28,代碼來源:AdminController.php


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