PHP code example of yieldstudio / laravel-mailjet-notifier
1. Go to this page and download the library: Download yieldstudio/laravel-mailjet-notifier library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yieldstudio / laravel-mailjet-notifier example snippets
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use YieldStudio\LaravelMailjetNotifier\MailjetEmailChannel;
class OrderConfirmation extends Notification
{
public function via(): array
{
return [MailjetEmailChannel::class];
}
public function toMailjetEmail($notifiable): MailjetEmailMessage
{
return (new MailjetEmailMessage())
->templateId(999999) // Replace with your template ID
->to($notifiable->firstname, $notifiable->email)
->variable('firstname', $notifiable->firstname)
->variable('order_ref', 'N°0000001');
}
}
namespace App\Notifications;
use Illuminate\Notifications\Notification
;use YieldStudio\LaravelMailjetNotifier\MailjetSmsChannel;
use YieldStudio\LaravelMailjetNotifier\MailjetSmsMessage;
class ResetPassword extends Notification
{
public function __construct(protected string $code)
{
}
public function via()
{
return [MailjetSmsChannel::class];
}
public function toMailjetSms($notifiable): MailjetSmsMessage
{
return (new MailjetSmsMessage())
->to($notifiable->phone)
->text(__('This is your reset code :code', ['code' => $this->code]));
}
}