This commit is contained in:
Paolo A
2024-08-13 13:44:16 +00:00
parent 1bbb23088d
commit e796d76612
4001 changed files with 30101 additions and 40075 deletions

22
vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php vendored Normal file → Executable file
View 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)
{