<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wantp / laravel-dingtalk-notification-channel example snippets
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Wantp\Notifications\Messages\DingTalkMessage;
use Wantp\Notifications\Messages\Message;
class YourNotification extends Notification
{
use Queueable;
public function via()
{
return ['dingtalk'];
}
public function toDingTalk($notifiable)
{
return (new DingTalkMessage())
->title('研发部测试通知')
->body('研发部测试通知,收到请忽略');
}
}
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notification;
class User extends Authenticatable
{
use Notifiable;
...
public function dingTalkUser()
{
return $this->hasOne(DingTalkUser::class);
}
public function routeNotificationForDingTalk(Notification $notification)
{
return $this->dingTalkUser->ding_talk_user_id;
}
}
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Wantp\Notifications\Messages\DingTalkMessage;
use Wantp\Notifications\Messages\Message;
class YourNotification extends Notification
{
use Queueable;
public function via()
{
return ['dingtalk'];
}
public function toDingTalk($notifiable)
{
return (new DingTalkMessage())
->link()
->title('研发部测试通知')
->body('研发部测试通知,收到请忽略')
->msgUrl('http://laravel.test/messages/1')
->msgPicUrl('http://laravel.test/message/pictures/1');
}
}
shell script
$ php artisan vendor:publish
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.