Fix ``AlerteStock`` to use ``name`` instead of non-existent ``title`` field on articles, so the article name actually appears in the email. Add ``lien_article`` variable with a direct link to the admin article edit page. Update the DB template with a button and text link.
50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Models\Core\Mail\MailTemplate;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailables\Address;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Spatie\MailTemplates\TemplateMailable;
|
|
|
|
class AlerteStock extends TemplateMailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
public $subject;
|
|
|
|
public $article;
|
|
|
|
public $offre;
|
|
|
|
public $stock_restant;
|
|
|
|
public $seuil;
|
|
|
|
public $lien_article;
|
|
|
|
public $lien_offre;
|
|
|
|
protected static $templateModelClass = MailTemplate::class;
|
|
|
|
public function __construct($offer)
|
|
{
|
|
$this->article = $offer->article->name ?? 'Article #'.$offer->article_id;
|
|
$this->offre = $offer->id;
|
|
$this->stock_restant = $offer->stock_current;
|
|
$this->seuil = $offer->minimum_ondemand;
|
|
$this->lien_article = url('/Admin/Shop/Articles/edit/'.$offer->article_id);
|
|
$this->lien_offre = url('/Admin/Shop/Offers/edit/'.$offer->id);
|
|
}
|
|
|
|
public function envelope()
|
|
{
|
|
return new Envelope(
|
|
from: new Address('boutique@jardinenvie.com', 'Jardin\'en\'Vie'),
|
|
subject: $this->subject,
|
|
);
|
|
}
|
|
}
|