<?php

declare(strict_types=1);

namespace App\Notifications\Reviews;

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

final class ReviewPostedNotification extends Notification implements ShouldQueue
{
    use Queueable;

    /**
     * Create a new notification instance.
     */
    public function __construct(
        public Review $review
    ) {
        //
    }

    /**
     * Get the notification's delivery channels.
     *
     * @return array<int, string>
     */
    public function via(object $notifiable): array
    {
        return ['database'];
    }

    /**
     * Get the array representation of the notification.
     *
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        return [
            'title' => 'New Review Received ⭐',
            'message' => $this->review->guest->name.' left a '.$this->review->rating.'-star review for '.$this->review->property->title,
            'icon' => 'star',
            'url' => route('guest.dashboard'),
            'review_id' => $this->review->id,
            'property_id' => $this->review->property_id,
        ];
    }
}
