Ejemplo n.º 1
0
 public function store(RegisterRequest $request, Registration $registration, RegistrationPeriod $PeriodModel, RegistrationStep $StepModel)
 {
     $input = $request->all();
     $registration->fill($input);
     $step = $StepModel->verifyEmail()->first();
     $period = $PeriodModel->current()->first();
     $username = daress_generate_username();
     $registration->username = $username;
     $registration->registration_period_id = $period->id;
     $registration->registration_step_id = $step->id;
     $registration->passeport_country_id = !empty($input['passeport_country_id']) ? $input['passeport_country_id'] : null;
     if ($registration->save()) {
         /** check for extra degrees an dstore them */
         $this->saveExtraDegrees($input, $registration->id);
         /** end check for extra degrees */
         event(new RegistrationCreated($registration));
         event(new RegistrationUpdated($registration));
         event(new RegistrationStepChanged($registration, ['comment' => 'تفعيل البريد الإلكتروني']));
         return view('registration::registrar.signup_success');
     } else {
         return redirect()->back()->with('error', 'لم يتم تسجيل طلبك ، المرجو التواصل مع الدعم الفني للمزيد من المعلومات');
     }
 }
Ejemplo n.º 2
0
 public function store(RegisterRequest $request)
 {
     $error = 0;
     $message = '';
     $period = Period::current()->first();
     if (!$period) {
         $error = 1;
         $message = 'لا يوجد فترة تسجيل حاليا';
         return response()->json(compact('error', 'message'), 200, [], JSON_NUMERIC_CHECK);
     }
     $input = $request->all();
     $registration = new Registration();
     $registration->fill(array_filter($input));
     if (!$request->has('academystructure_specialty_id') || empty($request->input('academystructure_specialty_id'))) {
         if ($specialty = Specialty::where('code', 'G')->first()) {
             $registration->academystructure_specialty_id = $specialty->id;
         } else {
             $registration->academystructure_specialty_id = 1;
         }
     }
     $step = RegistrationStep::verifyEmail()->first();
     if (($reason = $this->canApply($input)) !== true) {
         $error = 1;
         switch ($reason) {
             case 'ACTIVE':
                 $message = 'الرقم المدني الذي تحاول التسجيل به، مستخدم من طرف طالب منتظم.';
                 break;
             case 'DELAYED':
                 $message = 'الرقم المدني الذي تحاول التسجيل به، مستخدم من طرف طالب مؤجل.';
                 break;
             case 'NO_DEGREES':
                 $message = 'لم تقم بادخال بيانات الشهادة';
                 break;
             case 'NO_SPECIALITY':
                 $message = 'لم تقم باختيار تخصص المرجو اعادة اختيار تخصص.';
                 break;
         }
         return response()->json(compact('error', 'message'), 200, [], JSON_NUMERIC_CHECK);
     }
     $password = !empty($registration->password) ? $registration->password : mt_rand(6, 10);
     $username = daress_generate_username();
     $registration->username = $username;
     $registration->password = bcrypt($password);
     $registration->registration_period_id = $period->id;
     $registration->registration_step_id = $step ? $step->id : NULL;
     $registration->passeport_country_id = !empty($input['passeport_country_id']) ? $input['passeport_country_id'] : null;
     if (!$registration->save()) {
         $error = 1;
         $message = 'لم يتم تسجيل طلبك المرجو اعادة المحاولة لاحقا.';
     } else {
         $registration->generateCode();
         /** check for extra degrees an dstore them */
         foreach ($input['degrees'] as $degree) {
             $registration->degrees()->create($degree);
         }
         foreach ($input['files'] as $file) {
             $file = RegistrationFile::find($file['id']);
             $file->update(['registration_id' => $registration->id]);
         }
         /** end check for extra degrees */
         event(new RegistrationCreated($registration));
         event(new RegistrationEmailChanged($registration, ['password' => $password]));
         event(new RegistrationUpdated($registration));
         event(new RegistrationStepChanged($registration, ['password' => $password, 'comment' => 'تفعيل البريد الإلكتروني']));
     }
     if ($error == 1) {
         return response()->json(compact('error', 'message'), 200, [], JSON_NUMERIC_CHECK);
     }
     $message = 'أحسنت ـ تم ارسال رسالة الى بريدك الالكتروني تحتوي على المعلومات التي تحتاجها من أجل الولوج لبوابة المتقدم.';
     $token = Auth::guard('api_registration')->generateTokenById($registration->id);
     return response()->json(compact('token'), 200, [], JSON_NUMERIC_CHECK);
 }
Ejemplo n.º 3
0
 public function store(RegisterRequest $request, Registration $registration, RegistrationPeriod $PeriodModel, RegistrationStep $StepModel)
 {
     $input = $request->all();
     $period = $PeriodModel->current()->first();
     $registration->fill($input);
     if (!$request->has('academystructure_specialty_id')) {
         if ($specialty = Specialty::where('code', 'G')->first()) {
             $registration->academystructure_specialty_id = $specialty->id;
         } else {
             $registration->academystructure_specialty_id = NULL;
         }
     }
     $step = $StepModel->verifyEmail()->first();
     if (($reason = $this->canApply($input)) !== true) {
         $message = '';
         switch ($reason) {
             case 'ACTIVE':
                 $message = 'الرقم المدني الذي تحاول التسجيل به، مستخدم من طرف طالب منتظم.';
                 break;
             case 'DELAYED':
                 $message = 'الرقم المدني الذي تحاول التسجيل به، مستخدم من طرف طالب مؤجل.';
                 break;
         }
         return redirect()->back()->with('error', $message);
     }
     $username = daress_generate_username();
     $registration->username = $username;
     $registration->password = bcrypt(!empty($registration->contact_mobile) ? $registration->contact_mobile : mt_rand(6, 10));
     $registration->registration_period_id = $period->id;
     $registration->registration_step_id = $step->id;
     $registration->passeport_country_id = !empty($input['passeport_country_id']) ? $input['passeport_country_id'] : null;
     if ($registration->save()) {
         /** check for extra degrees an dstore them */
         $this->saveExtraDegrees($input, $registration->id);
         /** end check for extra degrees */
         event(new RegistrationCreated($registration));
         event(new RegistrationEmailChanged($registration));
         event(new RegistrationUpdated($registration));
         event(new RegistrationStepChanged($registration, ['comment' => 'تفعيل البريد الإلكتروني']));
         $message = 'أحسنت ـ تم ارسال رسالة الى بريدك الالكتروني تحتوي على المعلومات التي تحتاجها من أجل الولوج لبوابة المتقدم.';
         return view('registration::registrar.signup_success', compact('message'));
     } else {
         return redirect()->back()->with('error', 'لم يتم تسجيل طلبك ، المرجو التواصل مع الدعم الفني للمزيد من المعلومات');
     }
 }