$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, ] ), ]; } }