mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-08 13:53:17 +01:00
Scramble 0.13 moved the collected resource type of resource collections to a different template slot, which broke the custom paginated resource collection extension and the API docs export. Scramble now infers paginated responses natively, so the extension, the marker interface and the @return annotations that overrode the inference are removed. Scramble 0.13 also documents closure routes, so the API fallback routes are moved to a controller that is excluded from the docs. Add a test that exports the API docs.
39 lines
955 B
PHP
39 lines
955 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Resources\V1\Project;
|
|
|
|
use App\Models\Project;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
|
|
|
class ProjectCollection extends ResourceCollection
|
|
{
|
|
private bool $showBillableRates;
|
|
|
|
public function __construct($resource, bool $showBillableRates)
|
|
{
|
|
parent::__construct($resource);
|
|
$this->showBillableRates = $showBillableRates;
|
|
}
|
|
|
|
protected function collects(): ?string
|
|
{
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Transform the resource collection into an array.
|
|
*
|
|
* @return array<array<string, string|bool|int|null>>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return $this->collection->map(function (Project $project) use ($request): array {
|
|
return (new ProjectResource($project, $this->showBillableRates))
|
|
->toArray($request);
|
|
})->all();
|
|
}
|
|
}
|