php Laravel Notification类 - 通知Slack Channel

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Laravel Notification类 - 通知Slack Channel相关的知识,希望对你有一定的参考价值。

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\SlackMessage;
use Illuminate\Notifications\Notification;

class NotifyToSlackChannel 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 ['slack'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\SlackMessage
     */
    public function toSlack($notifiable)
    {
        return (new SlackMessage)
            ->content('Yuhuuuuuu!');
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}

以上是关于php Laravel Notification类 - 通知Slack Channel的主要内容,如果未能解决你的问题,请参考以下文章

Laravel 消息通知

Laravel 消息通知

laravel-push-notification 在响应正文中返回 html 标记

Laravel 5.3 通知与可邮寄

实现队列时,Laravel通知侦听器无用

根据自定义用户区域设置值发送 Laravel 通知