/** * Handle the event. * * @param RegistrationStepChanged $event * @return void */ public function handle(RegistrationStepChanged $event) { $registration = $event->registration; $registration->load('step', 'period', 'period.year'); $extra = $event->extra; $password = isset($extra['password']) ? $extra['password'] : ''; $step = $registration->step; if (empty($step->email_template)) { return true; } $template = str_replace(['{reg_portal}', '{debit}', '{name}', '{code}', '{password}', '{username}', '{year}', '{nid}'], [route('login.registrar'), $registration->debit, $registration->fullname, $registration->code, $registration->password, $registration->username, $registration->period->year->name, $registration->national_id], $step->email_template); $data = ['registration_id' => $registration->id, 'content' => $template]; RegistrationNotification::create($data); }