laravel Notification is missing toDatabase / toArray method

Viewed 429

I have multiple notifications in my app and most of them are working but one of them get this error :

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

the code :

<?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' => '...'
        ];
    }
}

I've tried to replace toArray with toDatabase but nothing changed I'm using Laravel 6.20.3 and my DataBase is Mysql 7.4.1

0 Answers
Related