25 lines
781 B
PHP
25 lines
781 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Client;
|
|
|
|
use App\Enums\ShiftDayEnum;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class ShiftResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'day_of_week' => $this->day_of_week,
|
|
'day_index' => $this->day_of_week ? ShiftDayEnum::from($this->day_of_week)->carbonDay() : null,
|
|
'date' => $this->date ? verta($this->date)->format('%Y/%m/%d') : null,
|
|
'date_raw' => $this->date?->format('Y-m-d'),
|
|
'start_time' => substr($this->start_time, 0, 5),
|
|
'end_time' => substr($this->end_time, 0, 5),
|
|
'is_active' => $this->is_active,
|
|
];
|
|
}
|
|
}
|