Files
ProxyPanel/app/Notifications/NodeDailyReport.php
2021-01-29 00:11:14 -05:00

51 lines
1.4 KiB
PHP

<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class NodeDailyReport extends Notification implements ShouldQueue
{
use Queueable;
private $data;
public function __construct($data)
{
$this->data = $data;
}
public function via($notifiable)
{
return sysConfig('node_daily_notification');
}
public function toMail($notifiable)
{
return (new MailMessage)
->subject(__('Nodes Daily Report'))
->markdown('mail.simpleMarkdown', ['title' => __('Nodes Daily Report'), 'content' => $this->markdownMessage(), 'url' => route('admin.node.index')]);
}
private function markdownMessage()
{
$content = '| '.trans('user.attribute.node').' | '.trans('notification.node.upload').' | '.trans('notification.node.download').' | '.trans('notification.node.total')." |\r\n| ------ | :------: | :------: | ------: |\r\n";
foreach ($this->data as $node) {
$content .= "| {$node['name']} | {$node['upload']} | {$node['download']} | {$node['total']} |\r\n";
}
return $content;
}
public function toCustom($notifiable)
{
return [
'title' => __('Nodes Daily Report'),
'content' => $this->markdownMessage(),
];
}
}