mysql laravel通知缺失toDatabase / toArray方法

sgtfey8w  于 2023-08-02  发布在  Mysql
关注(0)|答案(1)|浏览(116)

我的应用程序中有多个通知,其中大部分都在工作,但其中一个出现了以下错误:

laravel Notification is missing toDatabase / toArray method . at /var/www/vendor/laravel/framework/src/Illuminate/Notifications/Channels/DatabaseChannel.php:44

字符串
代码:

<?php

namespace App\Notifications\Notifications\NotifyBrand\Campaign;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class AfterCreateCampaignNotif extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct()
    {
     
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['mail','database'];
    }

    
    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->subject('subject')
            ->view('Emails.Template1', 
            [
                'BigTitle' => '...'
            ]);
    }

   
    public function toArray($notifiable)
    {
        return [
            'title' => '...'
        ];
    }
}


我尝试用 * toDatabase* 替换 toArray,但没有任何变化。我使用的是Laravel 6.20.3,我的数据库是Mysql 7.4.1

hs1ihplo

hs1ihplo1#

我帮助删除database函数via

public function via($notifiable)
{
    return ['mail','database'];
}

字符串

相关问题