当前位置: 首页>>代码示例>>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;未经允许,请勿转载。