当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::isJson方法代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\Request::isJson方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::isJson方法的具体用法?PHP Request::isJson怎么用?PHP Request::isJson使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Facades\Request的用法示例。


在下文中一共展示了Request::isJson方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate

 /**
  * Validate an array of attributes.
  *
  * @param ParameterBag|array $attributes
  * @param callable|null      $callback
  *
  * @throws ValidationException
  *
  * @return mixed
  */
 public function validate($attributes = [], callable $callback = null)
 {
     // Unwrap parameter bags
     if ($attributes instanceof ParameterBag) {
         $attributes = $attributes->all();
     }
     // Get attributes and create Validator
     $validation = $this->validator->make($attributes, $this->getRules($attributes), $this->getMessages());
     // Alter rules and stuff
     $validation = $this->alterValidation($validation);
     if ($validation->fails()) {
         $exception = ValidationException::class;
         if (class_exists('Dingo\\Api\\Exception\\ResourceException') && (Request::wantsJson() || Request::isJson())) {
             $exception = ResourceException::class;
         }
         throw new $exception('Validation failed', $validation->getMessageBag());
     } elseif ($callback) {
         return $callback($attributes, $this->model);
     }
     return true;
 }
开发者ID:anahkiasen,项目名称:arrounded,代码行数:31,代码来源:AbstractForm.php

示例2: push

 /**
  * Push responses to user agent (browser or external app)
  * 
  * @param  array $data Response dasta
  * @return mixed Response::json() or Redirect::to()
  * @static
  */
 public static function push($data = array())
 {
     $headers = isset($data['headers']) ? $data['headers'] : array();
     $secure = isset($data['secure']) ? $data['secure'] : NULL;
     $options = isset($data['options']) ? $data['options'] : NULL;
     $input = isset($data['input']) ? TRUE : FALSE;
     if (Request::ajax() or Request::isJson() or Request::wantsJson()) {
         $status = '200';
         return Response::json($data, $status, $headers, $options);
     } else {
         $status = '302';
         $response = Redirect::to($data['path'], $status, $headers, $secure);
         if (isset($data['errors'])) {
             $response->withErrors($data['errors']);
         }
         if (isset($data['messages'])) {
             $response->with($data['messages']);
         }
         if ($input) {
             $response->withInput();
         }
         return $response;
     }
 }
开发者ID:digideskio,项目名称:voip-id,代码行数:31,代码来源:Output.php

示例3: validateMD5Data

 /**
  * Validate the request MD5 data header.
  *
  * @param  string $clientSecret
  * @return boolean
  */
 public function validateMD5Data($clientSecret = '')
 {
     $md5 = $this->header('CONTENT_MD5');
     if (parent::isJson()) {
         $content = parent::getContent();
         if (empty($md5) and empty($content)) {
             return true;
         }
         return md5($content . $clientSecret) == $md5;
     }
     $input = $this->all();
     if (!empty($input)) {
         foreach ($input as $key => $item) {
             if (str_contains($key, '/')) {
                 unset($input[$key]);
             }
         }
     }
     if (empty($md5) and empty($input)) {
         return true;
     }
     return md5(http_build_query($input) . $clientSecret) == $md5;
 }
开发者ID:andrims21,项目名称:eBri,代码行数:29,代码来源:Request.php

示例4: __return

 /**
  * Return a response either view or json.
  *
  * @param  string    $status
  * @param  string    $message
  * @param  obj|array $data
  * @param  integer   $statusCode
  * @param  string    $viewName
  * @param  array     $headers
  * @param  string    $callback
  *
  * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response|\Illuminate\Routing\ResponseFactory
  */
 private function __return($status, $message, $data, $statusCode = 200, $viewName = 'data', $headers = [], $callback = 'callback')
 {
     if (Request::ajax() || Request::wantsJson() || Request::isJson() || Request::acceptsJson()) {
         return $this->responseInJson($status, $message, $data, $statusCode, $headers, $callback);
     }
     return $this->responseInView(collect(['message' => $message, 'data' => $data]), $viewName);
 }
开发者ID:multimedia-street,项目名称:common,代码行数:20,代码来源:ResponseTrait.php

示例5: all

 /**
  * @return array
  */
 public static function all()
 {
     return Request::isJson() ? Input::json()->all() : Input::all();
 }
开发者ID:rastaturin,项目名称:time_managment,代码行数:7,代码来源:MyInput.php


注:本文中的Illuminate\Support\Facades\Request::isJson方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。