<?php

namespace App\Notifications;

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

class ResetPasswordNotification extends Notification
{
    use Queueable;

    /**
     * Create a new notification instance.
     */
    public function __construct(
        private readonly string $token
    ) {
        //
    }

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

    /**
     * Get the mail representation of the notification.
     */
    public function toMail(object $notifiable): MailMessage
    {
        $frontendurl = rtrim(
            config('app.frontend_url'),
            '/'
        );

        $resetUrl = $frontendurl . '/reset-password?token='
            . urlencode($this->token)
            . '&email='
            . urlencode($notifiable->email);

        return (new MailMessage)
            ->subject('Şifrenizi Sıfırlayın')
            ->greeting('Merhaba!')
            ->line('Hesabınız için şifre sıfırlama talebi aldık.')
            ->action('Şifremi Sıfırla', $resetUrl)
            ->line('Bu bağlantıyı siz talep etmediyseniz herhangi bir işlem yapmanız gerekmez.');
    }

    /**
     * Get the array representation of the notification.
     *
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        return [
            //
        ];
    }
}
