本文整理汇总了PHP中Illuminate\Http\Request::pjax方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::pjax方法的具体用法?PHP Request::pjax怎么用?PHP Request::pjax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Http\Request
的用法示例。
在下文中一共展示了Request::pjax方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildFailedValidationResponse
/**
* Create the response for when a request fails validation.
*
* @param \Illuminate\Http\Request $request
* @param array $errors
* @return \Illuminate\Http\Response
*/
protected function buildFailedValidationResponse(Request $request, array $errors)
{
if ($request->ajax() && !$request->pjax() || $request->wantsJson()) {
return new JsonResponse($errors, 422);
}
return redirect()->to($this->getRedirectUrl())->withInput($request->input())->withErrors($errors, $this->errorBag());
}
示例2: 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->ajax() && !$request->pjax()) {
// return response([
// 'status' => 'error',
// 'message' => $e->getMessage()
// ], 500);
}
return parent::render($request, $e);
}
示例3: 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->ajax() && !$request->pjax() || $request->wantsJson()) {
return $this->sendResponseForApiException($e);
}
if (is_backend()) {
if ($e instanceof ModelNotFoundException) {
return $this->sendResponseForModelNotFound($e);
}
if ($e instanceof ValidationException) {
return $this->sendResponseForValidationError($request, $e);
}
return $this->renderControllerException($e);
}
return parent::render($request, $e);
}
示例4: handel
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param Closure $next
*
* @return mixed
*/
public function handel($request, Closure $next)
{
if (!$request->pjax()) {
return $next($request);
}
// First we get the request fragment, then we compile it to view cache
// next time we can request the cached view instead of manipulate complex
// string from response.
// 覆写 view factory
// 检查是否有已存的模版
// 检查是否过期
// (编译模版
// 取出一种的代码段另存)-》 如果不能直接取代码段-》 crawler dom 或 pjax
// 执行并返回
return $next($request);
}
示例5: pjax
/**
* Determine if the request is the result of an PJAX call.
*
* @return bool
* @static
*/
public static function pjax()
{
return \Illuminate\Http\Request::pjax();
}
示例6: buildSucessedResponse
/**
* Create the response for when a request successed.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
protected function buildSucessedResponse(Request $request)
{
if ($request->ajax() && !$request->pjax() || $request->wantsJson()) {
return new JsonResponse(['success' => 1], 200);
}
return redirect()->intended($this->getRequest()->get('redirect') ?: '/');
}
示例7: guessRequestType
/**
* @param \Illuminate\Http\Request $request
* @return string
*/
public function guessRequestType(Request $request)
{
$userAgent = strtolower($request->header('User-Agent'));
$contentType = array_get($request->getAcceptableContentTypes(), 0);
if (strpos($userAgent, 'googlebot') !== false) {
return 'googlebot';
} elseif ($request->ajax()) {
return 'ajax';
} elseif ($request->pjax()) {
return 'pjax';
} elseif ($contentType === null) {
return 'raw';
} elseif (Str::contains($contentType, ['application/rss+xml', 'application/rdf+xml', 'application/atom+xml'])) {
return 'feed';
} elseif ($request->wantsJson() || Str::contains($contentType, ['application/xml', 'text/xml'])) {
return 'api';
} elseif (!$request->acceptsHtml()) {
return 'other';
} elseif (Auth::check()) {
return 'user';
}
return 'public';
}
示例8: buildFailedValidationResponse
/**
* Create the response for when a request fails validation.
*
* @param \Illuminate\Http\Request $request
* @param array $errors
* @return \Illuminate\Http\Response
*/
protected function buildFailedValidationResponse(Request $request, array $errors)
{
if ($request->ajax() && !$request->pjax() || $request->wantsJson()) {
return new JsonResponse($errors, 422);
}
if ($request->ajax()) {
zbase()->json()->setVariable('_redirect', app(UrlGenerator::class)->previous());
} else {
return redirect()->to($this->getRedirectUrl())->withInput($request->input())->withErrors($errors, $this->errorBag());
}
}
示例9: convertValidationExceptionToResponse
/**
* Create a response object from the given validation exception.
*
* @param \Illuminate\Validation\ValidationException $e
* @param \Illuminate\Http\Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function convertValidationExceptionToResponse(ValidationException $e, $request)
{
if ($e->response) {
return $e->response;
}
$errors = $e->validator->errors()->getMessages();
if ($request->ajax() && !$request->pjax() || $request->wantsJson()) {
return response()->json($errors, 422);
}
return redirect()->back()->withInput($request->input())->withErrors($errors);
}