<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\SerializesModels;
use App\Models\Driver;

class DriverInvitationMail extends Mailable implements ShouldQueue
{
    use Queueable, SerializesModels;

    public function __construct(
        public Driver $driver,
        public string $temporaryPassword
    ) {
    }

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'You\'ve been added as a driver on TrueTrucker',
        );
    }

    public function content(): Content
    {
        return new Content(
            view: 'emails.driver-invitation',
            with: [
                'driver_name' => $this->driver->name,
                'email' => $this->driver->email,
                'temporary_password' => $this->temporaryPassword,
                'company_name' => $this->driver->company?->name ?? 'TrueTrucker',
            ]
        );
    }

    public function attachments(): array
    {
        return [];
    }
}
