| Current Path : /home/users/unlimited/www/foodbank.codeskitter.site/app/Notifications/ |
| Current File : /home/users/unlimited/www/foodbank.codeskitter.site/app/Notifications/OrderReportResponse.php |
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use NotificationChannels\Twilio\TwilioChannel;
use NotificationChannels\Twilio\TwilioSmsMessage;
class OrderReportResponse extends Notification implements ShouldQueue
{
use Queueable;
private $order;
private $status;
/**
* Create a new notification instance.
*
* @param $order
*/
public function __construct($order,$status)
{
$this->order = $order;
$this->status = trans('report_statuses.' . $status);
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
$array = ['database'];
if (setting('twilio_disabled') != true &&
!blank(setting('twilio_from')) &&
!blank(setting('twilio_account_sid')) &&
!blank(setting('twilio_account_sid'))
) {
array_push($array, TwilioChannel::class);
}
if (setting('mail_disabled') != true &&
!blank(setting('mail_host')) &&
!blank(setting('mail_username')) &&
!blank(setting('mail_password')) &&
!blank(setting('mail_port')) &&
!blank(setting('mail_from_name')) &&
!blank(setting('mail_from_address'))
) {
array_push($array, 'mail');
}
return $array;
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->subject("Response regarding your complaint against order #".$this->order->code)
->greeting('Hello '.$notifiable->name.',')
->line("We have taken your complaint against order ".$this->order->code.", in consideration.Your order is ".trans('report_statuses.' .$this->status))
->line('Thank you for staying with '.setting('site_name'));
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
/**
* @param $notifiable
* @return \NotificationChannels\Twilio\TwilioMessage|TwilioSmsMessage
*/
public function toTwilio($notifiable)
{
return (new TwilioSmsMessage())
->content("Your order #".$this->order->id." has been updated to".trans('order_status.' .$this->order->status));
}
}