<?php

namespace App\Notifications;

use App\Models\Client\Client;
use App\Models\Document\Document;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;

class ClientProofUploadedNotification extends Notification implements ShouldQueue
{
    use Queueable;

    /**
     * @param  string  $proofLabel  Human label for the proof, e.g. "Proof of ID".
     */
    public function __construct(
        public readonly Client $client,
        public readonly Document $document,
        public readonly string $proofLabel,
    ) {}

    public function via($notifiable): array
    {
        return ['database', 'broadcast'];
    }

    public function toArray($notifiable): array
    {
        return [
            'type'        => 'client_proof_uploaded',
            'title'       => $this->proofLabel . ' uploaded',
            'message'     => $this->client->full_name . ' uploaded their ' . $this->proofLabel,
            'client_id'   => $this->client->id,
            'client_name' => $this->client->full_name,
            'document_id' => $this->document->id,
            'proof_type'  => $this->proofLabel,
        ];
    }

    public function toBroadcast($notifiable): array
    {
        return $this->toArray($notifiable);
    }
}
