<?php

declare(strict_types=1);

namespace Maestro\Core\Modules\HourRegistration\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Maestro\Core\Modules\HourRegistration\Models\HourTimesheetWeek;

/** Database notification queued when any hour line needs lead approval after submit. */
class HourWeekAwaitingApprovalNotification extends Notification
{
    use Queueable;

    public function __construct(
        public HourTimesheetWeek $week,
    ) {}

    /**
     * @return list<string>
     */
    public function via(object $notifiable): array
    {
        return ['database'];
    }

    /**
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        $this->week->loadMissing('user');
        $employee = $this->week->user;

        return [
            'type' => 'hour_week_pending_approval',
            'hour_timesheet_week_id' => $this->week->id,
            'week_start' => $this->week->week_start->format('Y-m-d'),
            'employee_user_id' => $this->week->user_id,
            'employee_name' => $employee ? (string) $employee->name : '',
        ];
    }
}
