2026-05-11 13:30:24 +03:00

29 lines
852 B
PHP

<?php
namespace App\Http\Resources\Employee;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class LeaveHistoryResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'leave_id' => $this->leave_id,
'old_status' => $this->old_status,
'new_status' => $this->new_status,
'changed_at' => $this->changed_at?->format('Y-m-d H:i:s'),
'comment' => $this->comment,
'user' => $this->when(
$this->relationLoaded('user') && $this->user,
fn () => [
'id' => $this->user->id,
'name' => $this->user->name,
'email' => $this->user->email,
]
),
];
}
}