調整時間格式 修正 20250627
This commit is contained in:
parent
73b36906c7
commit
69007fbb86
@ -14,16 +14,14 @@ class RoomResource extends JsonResource
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'branch_id' => $this->branch_id,
|
||||
'type' => $this->type,
|
||||
'name' => $this->name,
|
||||
'floor' => $this->floor,
|
||||
'is_online' => $this->is_online,
|
||||
'status' => $this->status,
|
||||
'started_at' => optional($this->started_at)->timezone('Asia/Taipei')->format('Y-m-d H:i:s'),
|
||||
'ended_at' => optional($this->ended_at)->timezone('Asia/Taipei')->format('Y-m-d H:i:s'),
|
||||
];
|
||||
$array = parent::toArray($request);
|
||||
$array['started_at'] = $this->formatTaipei($this->started_at);
|
||||
$array['ended_at'] = $this->formatTaipei($this->ended_at);
|
||||
return $array;
|
||||
}
|
||||
|
||||
protected function formatTaipei(?Carbon $value): ?string
|
||||
{
|
||||
return $value ? $value->timezone('Asia/Taipei')->format('Y-m-d H:i:s') : null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user