Commaaa2
This commit is contained in:
22
vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php
vendored
Normal file → Executable file
22
vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php
vendored
Normal file → Executable file
@@ -22,13 +22,24 @@ class JsonResponse extends BaseJsonResponse
|
||||
* @param int $status
|
||||
* @param array $headers
|
||||
* @param int $options
|
||||
* @param bool $json
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data = null, $status = 200, $headers = [], $options = 0)
|
||||
public function __construct($data = null, $status = 200, $headers = [], $options = 0, $json = false)
|
||||
{
|
||||
$this->encodingOptions = $options;
|
||||
|
||||
parent::__construct($data, $status, $headers);
|
||||
parent::__construct($data, $status, $headers, $json);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function fromJsonString(?string $data = null, int $status = 200, array $headers = [])
|
||||
{
|
||||
return new static($data, $status, $headers, 0, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,11 +67,16 @@ class JsonResponse extends BaseJsonResponse
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setData($data = [])
|
||||
{
|
||||
$this->original = $data;
|
||||
|
||||
// Ensure json_last_error() is cleared...
|
||||
json_decode('[]');
|
||||
|
||||
if ($data instanceof Jsonable) {
|
||||
$this->data = $data->toJson($this->encodingOptions);
|
||||
} elseif ($data instanceof JsonSerializable) {
|
||||
@@ -100,6 +116,8 @@ class JsonResponse extends BaseJsonResponse
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setEncodingOptions($options)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user