File: /home/armgroup/libs/app/Notifications/DeliveryLink.php
<?php
namespace App\Notifications;
use App\Channels\SMSChannel;
use App\Models\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class DeliveryLink extends Notification
{
use Queueable;
public $order;
public $link;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(Order $order, string $link)
{
$this->order = $order;
$this->link = $link;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
$email = $notifiable->routes['mail'];
$mobile = $notifiable->routes[SMSChannel::class];
$available = [];
if ($email) {
array_push($available, 'mail');
}
if ($mobile) {
array_push($available, SMSChannel::class);
}
return $available;
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->subject("لینک تایید تحویل سفارش {$this->order->tracking_code}")
->line("برای تایید تحویل سفارش {$this->order->tracking_code} از لینک زیر استفاده کنید")
->action('مشاهده', $this->link)
->line('در صورت هر گونه مشکل میتوانید با پشتیبانی سایت تماس بگیرید.');
}
public function toSMS($notifiable)
{
return [
];
}
}