master

laravel/framework

Last updated at: 29/12/2023 09:24

AnonymousResourceCollection.php

TLDR

The provided file is a PHP class that extends the ResourceCollection class in the Illuminate\Http\Resources\Json namespace. It represents an anonymous resource collection.

Classes

AnonymousResourceCollection

This class represents an anonymous resource collection in the Illuminate\Http\Resources\Json namespace. It extends the ResourceCollection class and has the following properties and methods:

  • collects: The name of the resource being collected.
  • preserveKeys: Indicates if the collection keys should be preserved.
  • __construct($resource, $collects): Creates a new anonymous resource collection instance.
<?php

namespace Illuminate\Http\Resources\Json;

class AnonymousResourceCollection extends ResourceCollection
{
    /**
     * The name of the resource being collected.
     *
     * @var string
     */
    public $collects;

    /**
     * Indicates if the collection keys should be preserved.
     *
     * @var bool
     */
    public $preserveKeys = false;

    /**
     * Create a new anonymous resource collection.
     *
     * @param  mixed  $resource
     * @param  string  $collects
     * @return void
     */
    public function __construct($resource, $collects)
    {
        $this->collects = $collects;

        parent::__construct($resource);
    }
}