Files
Nexora/app/Notifications/DocumentUpdatedNotification.php
Javi 356f56eebd
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
first commit
2025-04-23 00:14:33 +06:00

61 lines
1.6 KiB
PHP

<?php
namespace App\Notifications;
use App\Models\Document;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class DocumentUpdatedNotification extends Notification implements ShouldQueue
{
use Queueable;
protected $document;
/**
* Create a new notification instance.
*/
public function __construct(Document $document)
{
$this->document = $document;
}
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail', 'database'];
}
/**
* Get the mail representation of the notification.
*/
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)
->subject('Nueva versión de documento: ' . $this->document->name)
->line('Se ha subido una nueva versión del documento.')
->action('Ver Documento', route('documents.show', $this->document))
->line('Gracias por usar nuestro sistema!');
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
'document_id' => $this->document->id,
'message' => 'Nueva versión del documento: ' . $this->document->name,
'url' => route('documents.show', $this->document)
];
}
}