TODO WeCom As Channel

This commit is contained in:
iVampireSP.com 2022-12-11 19:33:34 +08:00
parent e6fc281ec1
commit 997b58cda3
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
3 changed files with 64 additions and 3 deletions

View File

@ -17,7 +17,7 @@ public function __construct($servers)
$this->data = $servers;
}
public function broadcastOn()
public function broadcastOn(): Channel
{
return new Channel('servers');
}

View File

@ -44,12 +44,12 @@ public function __construct($user_id, $type, $message)
}
}
public function broadcastOn()
public function broadcastOn(): PrivateChannel
{
return new PrivateChannel('users.' . $this->user_id);
}
public function broadcastAs()
public function broadcastAs(): string
{
return 'user';
}

View File

@ -0,0 +1,61 @@
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class WeComChannel extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->line('The introduction to the notification.')
->action('Notification Action', url('/'))
->line('Thank you for using our application!');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}