<?php

namespace App\Notifications;

use App\Models\Listing;
use Illuminate\Notifications\Notification;

class NewScheduleAddedNotification extends Notification
{
    public function __construct(
        public Listing $listing,
        public int $scheduleCount = 1
    ) {}

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

    public function toArray(object $notifiable): array
    {
        $message = $this->scheduleCount > 1
            ? $this->listing->title . ' ilanına ' . $this->scheduleCount . ' yeni tarih eklendi.'
            : $this->listing->title . ' ilanına yeni bir tarih eklendi.';

        return [
            'type' => 'new_schedule_added',
            'title' => 'Favori İlanınızda Yeni Tarih!',
            'message' => $message,
            'listing_id' => $this->listing->id,
            'listing_title' => $this->listing->title,
            'schedule_count' => $this->scheduleCount,
            'action_url' => '/listings/' . $this->listing->id,
        ];
    }
}
