itsgoingd / clockwork

Clockwork - php dev tools in your browser - server-side component
https://underground.works/clockwork
MIT License
5.69k stars 321 forks source link

Bug: Exception when Notification class missing toArray() method #697

Closed Kristian-Palovic-Modified closed 7 months ago

Kristian-Palovic-Modified commented 7 months ago

Having the notification class:

namespace App\Notifications\Example;

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

class ExampleNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(
    ) {
    }

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

    public function toMail($notifiable)
    {
     ...
    }

    public function toDatabase($notifiable)
    {
     ...
    }
}

with clockwork enabled, calling $model->notify(new ExampleNotification()), class LaravelNotificationsDataSource.php@163 raises exception, as ExampleNotification is missing toArray() (instead using toDatabase).

Edit:

Testing with clockwork disabled and everything works as expected.

kristoffermodified commented 7 months ago

Seems to be fixed here: https://github.com/itsgoingd/clockwork/commit/40fb867e927f96287603ec21421307bdab28a671

itsgoingd commented 7 months ago

Hey, this was recently fixed in Clockwork 5.2.1, please make sure you are on the latest version.