Akaunting/app/Notifications/Common/Item.php

70 lines
1.5 KiB
PHP
Raw Normal View History

2017-11-21 20:37:15 +00:00
<?php
2018-06-09 23:48:51 +00:00
namespace App\Notifications\Common;
2017-11-21 20:37:15 +00:00
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;
class Item extends Notification
{
/**
* The item model.
*
* @var object
*/
public $item;
/**
* Create a notification instance.
*
* @param object $item
*/
public function __construct($item)
{
$this->item = $item;
}
/**
* Get the notification's channels.
*
* @param mixed $notifiable
* @return array|string
*/
public function via($notifiable)
{
return ['mail', 'database'];
}
/**
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
2018-02-25 16:00:31 +00:00
$message = (new MailMessage)
2018-09-29 14:37:55 +00:00
->line(trans('items.notification.message.out_of_stock', ['name' => $this->item->name]))
2018-11-06 08:50:40 +00:00
->action(trans('items.notification.button'), url('items/items', $this->item->id));
2018-02-25 16:00:31 +00:00
// Override per company as Laravel doesn't read config
$message->from(config('mail.from.address'), config('mail.from.name'));
return $message;
2017-11-21 20:37:15 +00:00
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
'item_id' => $this->item->id,
'name' => $this->item->name,
];
}
}