File: /home/armgroup/libs/app/Notifications/ProductAvailable.php
<?php
namespace App\Notifications;
use App\Channels\SMSChannel;
use App\Models\Product;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class ProductAvailable extends Notification implements ShouldQueue
{
use Queueable;
public $product;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(Product $product)
{
$this->product = $product;
}
public function viaQueues()
{
return [
'mail' => 'mail-queue',
SMSChannel::class => 'sms-queue',
];
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
$available = [];
if ($notifiable->email && $notifiable->email_verified_at) {
array_push($available, 'mail');
}
if ($notifiable->mobile && (settings('product-available-sms') == 1)) {
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->product->name.' موجود شد')
->line($this->product->name.' که درخواست موجود شدن آنرا داده بودید هماکنون موجود میباشد.')
->action(__('View'), route('products.show', $this->product->slug));
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
public function toSMS($notifiable)
{
return [
];
}
}