mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 08:12:17 +01:00
Add organization setting employees_can_see_billable_rates
This commit is contained in:
committed by
Constantin Graf
parent
9d279d4980
commit
51cd919db6
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user