mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 16:22:16 +01:00
51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Resources\V1\Organization;
|
|
|
|
use App\Http\Resources\V1\BaseResource;
|
|
use App\Models\Organization;
|
|
use Illuminate\Http\Request;
|
|
|
|
/**
|
|
* @property Organization $resource
|
|
*/
|
|
class OrganizationResource extends BaseResource
|
|
{
|
|
private bool $showBillableRate;
|
|
|
|
/**
|
|
* Create a new resource instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct(Organization $resource, bool $showBillableRate)
|
|
{
|
|
parent::__construct($resource);
|
|
|
|
$this->showBillableRate = $showBillableRate;
|
|
}
|
|
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, string|bool|int|null>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
/** @var string $id ID */
|
|
'id' => $this->resource->id,
|
|
/** @var string $name Name */
|
|
'name' => $this->resource->name,
|
|
/** @var bool $color Personal organizations automatically created after registration */
|
|
'is_personal' => $this->resource->personal_team,
|
|
/** @var int|null $billable_rate Billable rate in cents per hour */
|
|
'billable_rate' => $this->showBillableRate ? $this->resource->billable_rate : null,
|
|
/** @var bool $employees_can_see_billable_rates Can members of the organization with role "employee" see the billable rates */
|
|
'employees_can_see_billable_rates' => $this->resource->employees_can_see_billable_rates,
|
|
];
|
|
}
|
|
}
|