how to pass variable to an event listener laravel 1

how to pass variable to an event listener laravel

public function __construct(References $referee, Applications $user,Request $request)
{
$this->referee = $referee;
$this->user = $user;
$this->request=$request;
}
// ...and fire like this in controller  ...... event(new EmailRefereeOne($referee, $application,$request));
// So you can access in your listener like this $event->request->input('company_name_for_submission');

// Second option is easy: you can directly use Request facade in Listener like this without passing anything to the event. \Request::input( );

Here is what the above code is Doing:
1. The event is fired in the controller.
2. The event is received by the listener.
3. The listener is then able to access the request object.

Similar Posts