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


PHP Request::isXmlHttpRequest方法代碼示例

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


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

示例1: deleteMessage

 public function deleteMessage(Request $request, Message $message)
 {
     $result = $message->delete();
     if ($result) {
         if ($request->isXmlHttpRequest()) {
             return ['success' => true];
         }
         Flash::info('Message ' . $message->id . ' removed.');
         return redirect()->back();
     }
     if ($request->isXmlHttpRequest()) {
         return ['success' => false, 'message' => 'Can\'t remove message ' . $message->id];
     }
     return redirect()->back()->withErrors(['Can\'t remove message ' . $message->id]);
 }
開發者ID:paulchyrilov,項目名稱:hello_laravel,代碼行數:15,代碼來源:AdminController.php

示例2: getTownAutoComplete

 /**
  * @description: get town array with deleting duplicate entries
  * @return json array
  */
 public function getTownAutoComplete(Request $request)
 {
     if ($request->isXmlHttpRequest()) {
         // set url of data grand Lyon
         $json_url = "database/market.json";
         // get contents of file
         $json = file_get_contents($json_url);
         // decode json datas
         $datas = json_decode($json, TRUE);
         // get the multi json array
         $arrayFeatures = $datas["features"];
         // define a new empty array
         $arrayTown = array();
         // populate the new array with values we need
         foreach ($arrayFeatures as $feature) {
             array_push($arrayTown, $feature["properties"]["commune"]);
         }
         // get unique entry for array
         $result = array_unique($arrayTown);
         // get only vales of array after do array_unique (no index)
         $whatIReallyNeed = array_values($result);
         // set charset
         $charset = "UTF-8";
         //set content type
         $type = "application/json";
         // the best return ever ;)
         return response()->json($whatIReallyNeed)->header('Content-type', $type, 'charset', $charset);
     } else {
         // don't dream
         echo "what do you think dude !!!";
     }
 }
開發者ID:nayed,項目名稱:challenge-data-lyon,代碼行數:36,代碼來源:AutoCompleteController.php

示例3: shouldPassThrough

 /**
  * Determine if the request has a URI that should pass through CSRF verification.
  *
  * @param  \Illuminate\Http\Request $request
  * @return bool
  */
 protected function shouldPassThrough($request)
 {
     if ($request->segment(1) == trim(config('trungtnm.backend.uri'), '/') && $request->isXmlHttpRequest() && Sentinel::check()) {
         return true;
     }
     return false;
 }
開發者ID:trungtnm,項目名稱:backend,代碼行數:13,代碼來源:VerifyCsrfToken.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->isXmlHttpRequest()) {
         $this->errors['reason'] = 'Not XMLHttpRequest';
         return json_encode($this->errors);
     }
     return $next($request);
 }
開發者ID:satishux,項目名稱:ytm,代碼行數:15,代碼來源:CheckAjaxRequest.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $role = false)
 {
     $isAjaxRequest = $request->isXmlHttpRequest() || $request->ajax() || $request->wantsJson();
     if (!$isAjaxRequest) {
         return redirect('/');
     }
     return $next($request);
 }
開發者ID:Orvo,項目名稱:mlraamattu,代碼行數:15,代碼來源:AjaxRequest.php

示例6: delete

 public function delete(Request $request, Category $category)
 {
     $category->delete();
     if ($request->isXmlHttpRequest()) {
         return response(json_encode(['success' => true]))->header('Content-type', 'application/json');
     } else {
         return redirect('/category');
     }
 }
開發者ID:rajinha92,項目名稱:laravel-skills-test2,代碼行數:9,代碼來源:CategoryController.php

示例7: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $exception)
 {
     if ($request->isXmlHttpRequest() || $request->ajax() || $request->is('remote/*')) {
         $response = response()->json(['error' => $exception instanceof DisplayException ? $exception->getMessage() : 'An unhandled error occured while attempting to process this request.'], 500);
         // parent::render() will log it, we are bypassing it in this case.
         Log::error($exception);
     }
     return isset($response) ? $response : parent::render($request, $exception);
 }
開發者ID:Pterodactyl,項目名稱:Panel,代碼行數:16,代碼來源:Handler.php

示例8: shouldCache

 /**
  * Determine if the given request should be cached;.
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return bool
  */
 public function shouldCache(Request $request)
 {
     if ($request->isXmlHttpRequest()) {
         return false;
     }
     if ($this->isRunningInConsole()) {
         return false;
     }
     return $request->isMethod('get');
 }
開發者ID:sdebacker,項目名稱:laravel-responsecache,代碼行數:17,代碼來源:CacheAllGetRequests.php

示例9: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($this->isHttpException($e)) {
         if ($request->isXmlHttpRequest()) {
             return response()->json(['ret' => 404, 'msg' => 'not fund']);
         }
         return $this->renderHttpException($e);
     } else {
         return parent::render($request, $e);
     }
 }
開發者ID:xincap,項目名稱:erp,代碼行數:18,代碼來源:Handler.php

示例10: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     }
     // add handler for Ajax requests
     if ($request->isXmlHttpRequest()) {
         return Response::json(['status' => '500', 'message' => $e->getMessage()], 500);
     }
     return parent::render($request, $e);
 }
開發者ID:kcardina,項目名稱:bmooc-laravel,代碼行數:18,代碼來源:Handler.php

示例11: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot(Request $request)
 {
     if ($this->app->runningInConsole()) {
         return false;
     }
     if ($request->isXmlHttpRequest() || $request->ajax() || $request->wantsJson()) {
         return false;
     }
     $content_pages = Contentpage::pinned()->get();
     view()->share('content_pages', $content_pages);
 }
開發者ID:Orvo,項目名稱:mlraamattu,代碼行數:16,代碼來源:ViewServiceProvider.php

示例12: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     }
     if (config('app.debug')) {
         if ($request->isJson() || $request->isXmlHttpRequest()) {
             return response(['error' => ['exception' => class_basename($e) . ' in ' . basename($e->getFile()) . ' line ' . $e->getLine() . ': ' . $e->getMessage()]], 500);
         }
         return $this->renderExceptionWithWhoops($e);
     }
     return parent::render($request, $e);
 }
開發者ID:RoryStolzenberg,項目名稱:spacexstats,代碼行數:20,代碼來源:Handler.php

示例13: store

 /**
  * @param Storage $storage
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|string
  */
 public function store(Storage $storage, Request $request)
 {
     if ($request->isXmlHttpRequest()) {
         $image = $request->file('image');
         $timestamp = $this->getFormattedTimestamp();
         $savedImageName = $this->getSavedImageName($timestamp, $image);
         $imageUploaded = $this->uploadImage($image, $savedImageName, $storage);
         if ($imageUploaded) {
             $data = ['original_path' => asset('/images/' . $savedImageName)];
             return json_encode($data, JSON_UNESCAPED_SLASHES);
         }
         return "uploading failed";
     }
 }
開發者ID:kilis,項目名稱:carshop,代碼行數:19,代碼來源:ImageController.php

示例14: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show(Request $request)
 {
     //Recupera los datos de referencia para crear la tabla de préstamos
     if ($request->isXmlHttpRequest()) {
         $monto = $request->get('monto');
         $quincenas = $request->get('quincenas');
         $interes_anual = DB::table('references')->where('months', $quincenas)->value('value') / 100;
         $mi_prestamo = new FinantialClass($interes_anual, $quincenas, $monto, 0.16);
         $mi_tabla = FinantialClass::create_amorti($mi_prestamo);
         return json_encode($mi_tabla);
     } else {
         return "Datos invalidos";
     }
 }
開發者ID:ubaldeitor,項目名稱:dinkbit,代碼行數:20,代碼來源:ReferencesController.php

示例15: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Exception $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($request->isXmlHttpRequest()) {
         // moze lepiej bedzie uzyc wantsJson()?
         $response = ['error' => 'Przepraszamy, ale coś poszło nie tak. Prosimy o kontakt z administratorem.'];
         if (config('app.debug')) {
             $response['exception'] = get_class($e);
             $response['message'] = $e->getMessage();
             $response['trace'] = $e->getTrace();
         }
         $status = 500;
         if ($this->isHttpException($e)) {
             $status = $e->getStatusCode();
         }
         return response()->json($response, $status);
     }
     return parent::render($request, $e);
 }
開發者ID:furious-programming,項目名稱:coyote,代碼行數:25,代碼來源:Handler.php


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