Closed ltlacerda closed 1 year ago
My mistake. I just added one more argument to handle() and now I have sender and recipient:
public function handle(object $sender, object $recipient): void { dd($sender->name.' '.$recipient->name); }
I'm glad it's fixed, and I wish you the best, thanks for using Laravel Acquaintances <3
Thank you very much, bro! You saved me a lot of work. I wish you the best.
The event is being listened to by FriendshipSentListener in EventServiceProvider.php:
'acq.friendships.sent' => [ FriendshipSentListener::class ]
Here the FriendshipSentListener's handle() method:
public function handle(object $event): void { dd($event); }
$event comes only with the sender model, not an array or object containing the sender and recipient model.
When I change handle method to receive $event as array, I get the following error:
TypeError: App\Listeners\FriendshipSentListener::handle(): Argument #1 ($event) must be of type array, App\Models\User given, called in /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php on line 441 in file /var/www/html/app/Listeners/FriendshipSentListener.php on line 21
So I understand that $event only corresponds to the sender model.
Am I doing something wrong?
Thanks in advance.