芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/www/vendor/laravel/framework/src/Illuminate/Http/Resources/Json/JsonResource.php
resource = $resource; } /** * Create a new resource instance. * * @param mixed ...$parameters * @return static */ public static function make(...$parameters) { return new static(...$parameters); } /** * Create a new anonymous resource collection. * * @param mixed $resource * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection */ public static function collection($resource) { return tap(new AnonymousResourceCollection($resource, static::class), function ($collection) { if (property_exists(static::class, 'preserveKeys')) { $collection->preserveKeys = (new static([]))->preserveKeys === true; } }); } /** * Resolve the resource to an array. * * @param \Illuminate\Http\Request|null $request * @return array */ public function resolve($request = null) { $data = $this->toArray( $request = $request ?: Container::getInstance()->make('request') ); if ($data instanceof Arrayable) { $data = $data->toArray(); } elseif ($data instanceof JsonSerializable) { $data = $data->jsonSerialize(); } return $this->filter((array) $data); } /** * Transform the resource into an array. * * @param \Illuminate\Http\Request $request * @return array */ public function toArray($request) { if (is_null($this->resource)) { return []; } return is_array($this->resource) ? $this->resource : $this->resource->toArray(); } /** * Convert the model instance to JSON. * * @param int $options * @return string * * @throws \Illuminate\Database\Eloquent\JsonEncodingException */ public function toJson($options = 0) { $json = json_encode($this->jsonSerialize(), $options); if (JSON_ERROR_NONE !== json_last_error()) { throw JsonEncodingException::forResource($this, json_last_error_msg()); } return $json; } /** * Get any additional data that should be returned with the resource array. * * @param \Illuminate\Http\Request $request * @return array */ public function with($request) { return $this->with; } /** * Add additional meta data to the resource response. * * @param array $data * @return $this */ public function additional(array $data) { $this->additional = $data; return $this; } /** * Customize the response for a request. * * @param \Illuminate\Http\Request $request * @param \Illuminate\Http\JsonResponse $response * @return void */ public function withResponse($request, $response) { // } /** * Set the string that should wrap the outer-most resource array. * * @param string $value * @return void */ public static function wrap($value) { static::$wrap = $value; } /** * Disable wrapping of the outer-most resource array. * * @return void */ public static function withoutWrapping() { static::$wrap = null; } /** * Transform the resource into an HTTP response. * * @param \Illuminate\Http\Request|null $request * @return \Illuminate\Http\JsonResponse */ public function response($request = null) { return $this->toResponse( $request ?: Container::getInstance()->make('request') ); } /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\JsonResponse */ public function toResponse($request) { return (new ResourceResponse($this))->toResponse($request); } /** * Prepare the resource for JSON serialization. * * @return array */ public function jsonSerialize() { return $this->resolve(Container::getInstance()->make('request')); } }