I'm trying to pass data to the method broadcastAs, but I keep getting the error Too few arguments to function App\Events\NotifyUser::broadcastAs()
. Below is what I have tried.
I'm calling the event on the Controller this way:
event(new NotifyUser('8', 'banned'));
And I'm trying to access the data on the event this way:
public $user;
public $msg;
public function __construct($user, $msg)
{
$this->user = $user; //8
$this->msg = $msg; //banned
}
public function broadcastAs($user)
{
return "user-logged-$user";
}
It works just fine without the $user variable in the broadcastAs.