/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (registrar()) { $has_notifications = RegistrationNotification::where('registration_id', registrar()->id)->where('seen', 0)->count(); $notification_routes = ['registration.registrar.notifications', 'registration.registrar.notifications.update']; if ($has_notifications && !in_array(Route::getCurrentRoute()->getName(), $notification_routes)) { return redirect()->route('registration.registrar.notifications')->with('message', 'عليك التأكيد بأنك قرأت هذه الإشعارات.'); } } return $next($request); }
/** * 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); }
public function update(UpdateNotificationRequest $request) { $registrar = registrar(); RegistrationNotification::where('registration_id', $registrar->id)->where('seen', 0)->where('id', $request->input('notification_id'))->update(['seen' => 1]); return redirect()->route('registration.registrar.index'); }