Add organization setting employees_can_see_billable_rates

This commit is contained in:
Constantin Graf
2024-10-01 18:14:26 +02:00
committed by Constantin Graf
parent 9d279d4980
commit 51cd919db6
13 changed files with 269 additions and 15 deletions

View File

@@ -5,14 +5,39 @@ declare(strict_types=1);
namespace App\Http\Resources\V1\Project;
use App\Http\Resources\PaginatedResourceCollection;
use App\Models\Project;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Pagination\LengthAwarePaginator;
class ProjectCollection extends ResourceCollection implements PaginatedResourceCollection
{
private bool $showBillableRates;
/**
* The resource that this resource collects.
*
* @var string
* @param LengthAwarePaginator<Project> $resource
*/
public $collects = ProjectResource::class;
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();
}
}