junaidnasir/larainvite

Undefined property: Junaidnasir\Larainvite\Events\Invited::$email

Opened this issue · 2 comments

Hello,

I have this error when i tried to send an invitation to my user.

When I upgraded to version 4.x, I had to change the event listener like that:

Before

// App\Providers\EventServiceProvider
protected $listen = [
        'junaidnasir.larainvite.invited' => [
            'App\Listeners\UserInvite',
        ],
];

After

// App\Providers\
protected $listen = [
        Invited::class => [
            'App\Listeners\UserInvite',
        ],
];

After that, I had the following error:
Undefined property: Junaidnasir\Larainvite\Events\Invited::$email

For now, I found this fix:

Before

// App\Listeners\UserInvite
public function handle($invitation)
{
        Mail::to($invitation->email)->send(new UserInviteMail($invitation->code, $invitation->email));
}

After

// App\Listeners\UserInvite
public function handle($invitation)
{
        Mail::to($invitation->invitation->email)->send(new UserInviteMail($invitation->invitation->code, $invitation->invitation->email));
}

Ran into the same problem was able to fix with BenjaminDelacombaz fix.

Same issue here. Solved with the proposed solution by BenjaminDelacombaz.