123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- namespace addons\shopro\notification;
- use addons\shopro\channel\Database;
- use addons\shopro\channel\Websocket;
- use addons\shopro\notification\traits\Notification as NotificationTrait;
- class CustomeNotice extends Notification
- {
- use NotificationTrait;
-
- public $delay = 0;
- public $receiver_type = 'admin';
-
- public $notification_type = 'system';
-
- public $event = 'custom';
-
- public $channels = [];
-
- public $data = [];
- public $template = [
- 'MessageDefaultContent' => '',
- ];
-
- public $returnField = [];
- public function __construct($params = [], $data = [])
- {
- $this->receiver_type = $params['receiver_type'] ?? 'admin';
- $this->notification_type = $params['notification_type'] ?? 'system';
- $this->channels = $params['channels'] ?? [];
- $this->data = $data;
- }
- public function channels($notifiable)
- {
-
- $channels = [Database::class, Websocket::class];
- return array_merge($channels, $this->channels);
- }
-
- public function toDatabase($notifiable)
- {
- $params = $this->getArray();
- return $params;
- }
-
- public function toWebsocket($notifiable)
- {
- $params = $this->getArray();
- return $params;
- }
-
- protected function getArray()
- {
- $params['data'] = [
- 'jump_url' => $this->data['jump_url'] ?? ''
- ];
- $params['message_type'] = 'notification';
- $params['class_name'] = static::class;
- $params['message_text'] = $this->data['message_text'] ?? '';
- $params['message_title'] = $this->data['message_title'] ?? '';
- $this->template['MessageDefaultContent'] = $this->data['message_title'] ?? '';
-
- return $params;
- }
- }
|