Hi all,
I just want to pass the following var $companyName
$companyName = $request->input('company_name_for_submission');
Which I newup from my controller like so: event(new EmailRefereeOne($referee, $application));
To my event and listener which are as follows:
// Event
class EmailRefereeOne extends Event
{
use SerializesModels;
public $referee;
/**
* @var Applications
*/
public $user;
/**
* Create a new event instance.
*
* @param $referee
*/
public function __construct(References $referee, Applications $user)
{
$this->referee = $referee;
$this->user = $user;
}
/**
* Get the channels the event should be broadcast on.
*
* @return array
*/
public function broadcastOn()
{
return [];
}
}
// Listener
class EmailRefereeOneListener implements ShouldQueue
{
use InteractsWithQueue;
private $referee;
/**
* @var Applications
*/
private $user;
/**
* Create the event listener.
*
* @param $referee
*/
public function __construct(References $referee, Applications $user)
{
$this->referee = $referee;
$this->user = $user;
}
/**
* Handle the event.
*
* @param EmailRefereeOne $event
* @return void
*/
public function handle(EmailRefereeOne $event)
{
// Handle data attributes
$data = array(
'worker' => ucwords($event->user->first_name) .' '. ucwords($event->user->surname),
'company' => '', //Need that $companyName variable here
'email' => $event->referee->referee_email,
'refereeName' => $event->referee->referee_name
);
// Send the email
Mail::send('emails/applications/submission', $data, function( $message ) use ($data)
{
$message->to($data['email'])
->from(config('custom.noreplyemail'), 'Testing')
->subject('Test Subject');
});
}
So how can I pass the $companyName variable through?
I have tried assigning $companyName but returns the following error:
BindingResolutionException in Container.php line 823:
Unresolvable dependency resolving [Parameter #2 [ <required> $companyName ]] in class App\Listeners\EmailRefereeOneListener