<?php

namespace App\Notifications;

use App\Models\Request;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class NewRequestNotification extends Notification implements ShouldQueue
{
    use Queueable;

    protected $request;

    public function __construct(Request $request)
    {
        $this->request = $request;
    }

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

    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->subject('New Request Created')
            ->greeting('Hello ' . $notifiable->name)
            ->line('A new request has been created by ' . $this->request->user->name)
            ->line('Request Type: ' . $this->request->requestType->name)
            ->line('Note: ' . $this->request->note)
            ->action('View Request', url('/requests/' . $this->request->id))
            ->line('Please review and take necessary action.');
    }

    public function toArray($notifiable)
    {
        return [
            'request_id' => $this->request->id,
            'user_id' => $this->request->user_id,
            'request_type' => $this->request->requestType->name,
            'note' => $this->request->note,
            'created_at' => $this->request->created_at,
        ];
    }
} 