36 lines
991 B
PHP
36 lines
991 B
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\Producto;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\Notification;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
|
class StockMinimoNotificacion extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
public Producto $producto;
|
|
|
|
public function __construct(Producto $producto)
|
|
{
|
|
$this->producto = $producto;
|
|
}
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['mail'];
|
|
}
|
|
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
return (new MailMessage)
|
|
->subject('⚠️ Stock mínimo alcanzado')
|
|
->line("El producto '{$this->producto->nombre}' ha alcanzado el stock mínimo.")
|
|
->line("Stock actual: {$this->producto->stock}")
|
|
->line("Stock mínimo: {$this->producto->stock_minimo}")
|
|
->action('Ver producto', url("/admin/productos/{$this->producto->id}/edit")); // Ajusta ruta si usas Filament
|
|
}
|
|
}
|