JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr{ gilour

File "CsvExportReadyNotif-20260314162230.php"

Full Path: /home/markqprx/iniasli.pro/Csv/CsvExportReadyNotif-20260314162230.php
File size: 1.69 KB
MIME-type: text/x-php
Charset: utf-8

<?php

namespace Common\Csv;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class CsvExportReadyNotif extends Notification
{
    use Queueable;

    public function __construct(
        protected CsvExport $csvExport,
        protected string $exportName
    ) {
    }

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

    public function toMail($notifiable): MailMessage
    {
        return (new MailMessage())
            ->line($this->primaryLine())
            ->line(
                __(
                    'This download link will only work if you are logged in as user who has requested the export and it will expire in one day.',
                ),
            )
            ->action('Download', $this->csvExport->downloadLink());
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable): array
    {
        return [
            'mainAction' => [
                'Label' => 'Download',
                'action' => $this->csvExport->downloadLink(),
            ],
            'lines' => [
                [
                    'content' => $this->primaryLine(),
                ],
                [
                    'content' => __(
                        'This download link will expire in one day.',
                    ),
                ],
            ],
        ];
    }

    protected function primaryLine(): string
    {
        return __('“:name“ CSV export is ready to download.', [
            'name' => ucfirst($this->exportName),
        ]);
    }
}