优化代码
This commit is contained in:
parent
3be7700971
commit
df7d20408d
@ -7,7 +7,6 @@
|
|||||||
use App\Notifications\Channels\WeComChannel;
|
use App\Notifications\Channels\WeComChannel;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
class WorkOrder extends Notification implements ShouldQueue
|
class WorkOrder extends Notification implements ShouldQueue
|
||||||
@ -29,26 +28,9 @@ public function __construct(WorkOrderModel $work_order)
|
|||||||
/**
|
/**
|
||||||
* Get the notification's delivery channels.
|
* Get the notification's delivery channels.
|
||||||
*/
|
*/
|
||||||
public function via(WorkOrderModel $workOrder): array
|
public function via(): array
|
||||||
{
|
{
|
||||||
$methods = [WeComChannel::class, WebChannel::class];
|
return [WeComChannel::class, WebChannel::class];
|
||||||
|
|
||||||
if (in_array($workOrder->status, ['processing', 'replied'])) {
|
|
||||||
$methods[] = 'mail';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $methods;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the mail representation of the notification.
|
|
||||||
*/
|
|
||||||
public function toMail(WorkOrderModel $workOrder): MailMessage
|
|
||||||
{
|
|
||||||
return (new MailMessage)
|
|
||||||
->subject('工单: '.$workOrder->title.' 状态更新。')
|
|
||||||
->line('我们查阅了您的工单并做出了相应处理。')
|
|
||||||
->line('请前往我们的仪表盘继续跟进问题。');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,23 +49,10 @@ public function toWeCom(WorkOrderModel $workOrder): false|array
|
|||||||
{
|
{
|
||||||
$workOrder->load(['module', 'user']);
|
$workOrder->load(['module', 'user']);
|
||||||
|
|
||||||
$wecom_key = config('settings.wecom.robot_hook.default');
|
|
||||||
|
|
||||||
if ($workOrder->module) {
|
|
||||||
$module = $workOrder->module;
|
|
||||||
|
|
||||||
$wecom_key = $module->makeVisible(['wecom_key'])->wecom_key ?? $wecom_key;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'key' => $wecom_key,
|
'key' => $workOrder->wecom_key,
|
||||||
'view' => 'notifications.work_order',
|
'view' => 'notifications.work_order',
|
||||||
'data' => $workOrder,
|
'data' => $workOrder,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function toBroadcast(WorkOrderModel $workOrder): BroadcastMessage
|
|
||||||
// {
|
|
||||||
// return new BroadcastMessage($workOrder->toArray());
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user