for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Owowagency\LaravelMedia\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class MediaResourceCollection extends ResourceCollection
{
/**
* Force the resource to use its own array structure instead of possible
* exceptions.
*
* @var bool
*/
public $forceMediaResource = false;
* Create a new resource instance.
* @param mixed $resource
* @param bool $forceMediaResource
public function __construct($resource, bool $forceMediaResource = false)
parent::__construct($resource);
$this->forceMediaResource = $forceMediaResource;
}
* Transform the resource collection into an array.
* @param \Illuminate\Http\Request $request
* @return array
public function toArray($request): array
return $this->resource->map(function (MediaResource $resource) use ($request) {
$request
This check looks for imports that have been defined, but are not used in the scope.
$resource->forceMediaResource = $this->forceMediaResource;
return $resource;
})->toArray();
This check looks for imports that have been defined, but are not used in the scope.