beyondcode / invoker-community

74 stars 2 forks source link

Call to undefined method __invoke() on event #294

Closed joostvanhoof closed 1 year ago

joostvanhoof commented 2 years ago

OS: darwin Invoker Version: 2.8.0 Laravel Version: 9.14.1 Local project: true PHP Binary: /opt/homebrew/Cellar/php/8.0.9/bin/php

I'm getting the following error when trying to dispatch an event through the Invoker UI:

Call to undefined method App\Events\User\UserOnboarded::__invoke()

My event is defined as below, which is more or less the same as how it would be defined when generating an event with php artisan make:event: using this command will also not generate the __invoke() method.

namespace App\Events\User;

use App\Models\User;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class UserOnboarded
{
    use Dispatchable, SerializesModels;

    public $user;

    public function __construct(User $user)
    {
        $this->user = $user;
    }
}
mpociot commented 1 year ago

This will be fixed in the next version of Invoker.

RealMrHex commented 1 year ago

Same here!

laocoi commented 10 months ago

Use event instead of dispatch

event(new \App\Events\User\UserOnboarded());