/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $period = RegistrationPeriod::current()->first(); $period_id = $period ? $period->id : NULL; $user = Auth::guard('api_registration')->user(); return ['contact_email' => 'required|unique:registrations,contact_email,' . $user->id . ',id,registration_period_id,' . $period_id . '|max:255']; }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $period = RegistrationPeriod::current()->first(); $period_id = $period ? $period->id : NULL; $skill_levels = implode(',', array_keys(config('registration.skill_levels'))); $social_status = implode(',', array_keys(config('registration.social_status'))); return ['first_name' => 'required|max:255|min:2', 'second_name' => 'required|max:255|min:2', 'third_name' => 'required|max:255|min:2', 'fourth_name' => 'max:255', 'last_name' => 'required|max:255|min:2', 'last_name_latin' => 'required|max:255|min:2', 'fourth_name_latin' => 'max:255', 'third_name_latin' => 'required|max:255|min:2', 'second_name_latin' => 'required|max:255|min:2', 'first_name_latin' => 'required|max:255|min:2', 'gender' => 'required|in:f,m', 'birthday' => 'required|date', 'passeport_country_id' => 'exists:lists_countries,id|required_with:passeport_number', 'nationality_type' => 'in:O,E|required', 'passeport_issued' => 'date|required_with:passeport_number', 'passeport_expire' => 'date|required_with:passeport_number', 'stay_type' => 'sometimes|in:work,companion,tourism,non_resident', 'stay_expire' => 'required_unless:stay_type,non_resident', 'national_id' => 'required', 'contact_region' => '', 'contact_postalbox' => 'required|max:255', 'birth_country_id' => 'required|exists:lists_countries,id', 'nationality_country_id' => 'sometimes|required|exists:lists_countries,id', 'nationality_city_id' => 'sometimes|required|exists:lists_cities,id', 'nationality_state_id' => 'sometimes|required|exists:lists_states,id', 'contact_country_id' => 'required|exists:lists_countries,id', 'contact_city_id' => 'sometimes|required|exists:lists_cities,id', 'contact_state_id' => 'sometimes|required|exists:lists_states,id', 'contact_email' => 'required|unique:registrations,contact_email,' . $this->registration_id . ',id,registration_period_id,' . $period_id . '|max:255', 'contact_mobile' => 'required|numeric', 'contact_phone' => 'numeric', 'contact_fax' => 'numeric', 'social_status' => 'required|in:' . $social_status, 'social_job_status' => 'required', 'social_job' => 'required_if:social_job_status,employed', 'social_job_start' => 'required_if:social_job_status,employed', 'social_experience' => 'required_if:social_job_status,employed', 'social_job_employer' => 'required_if:social_job_status,employed', 'social_job_country_id' => 'required_if:social_job_status,employed|exists:lists_countries,id', 'social_job_city_id' => 'required_if:social_job_status,employed|exists:lists_cities,id', 'health_status' => 'in:0,1|required', 'health_disabled_type' => 'required_if:health_status,disabled', 'health_disabled_size' => 'required_if:health_status,disabled', 'computer_skills' => 'in:' . $skill_levels, 'internet_skills' => 'in:' . $skill_levels, 'internet_link' => '', 'cyber_cafe' => '', 'computer_availability' => '', 'reference' => 'in:iiswebsite,iisewebsite,iisfriend,iisefriend,other', 'reference_other' => 'required_if:reference,other']; }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $period = RegistrationPeriod::current()->first(); $period_id = $period ? $period->id : NULL; if (App::environment() == 'local') { return ['first_name' => 'required', 'contact_email' => 'required|unique:registrations,contact_email,NULL,id,registration_period_id,' . $period_id . '|max:255', 'contact_mobile' => 'required|min:8|max:16', 'national_id' => 'required|unique:registrations,national_id,NULL,id,registration_period_id,' . $period_id]; } $skill_levels = implode(',', array_keys(config('registration.skill_levels'))); $social_status = implode(',', array_keys(config('registration.social_status'))); return ['first_name' => 'required|max:255|min:2', 'second_name' => 'required|max:255|min:2', 'third_name' => 'required|max:255|min:2', 'fourth_name' => 'max:255', 'last_name' => 'required|max:255|min:2', 'last_name_latin' => 'required|max:255|min:2', 'fourth_name_latin' => 'max:255', 'third_name_latin' => 'required|max:255|min:2', 'second_name_latin' => 'required|max:255|min:2', 'first_name_latin' => 'required|max:255|min:2', 'gender' => 'required|in:f,m', 'birthday' => 'required|date', 'nationality_type' => 'in:O,E|required', 'passeport_issued' => 'date|required_with:passeport_number', 'passeport_country_id' => 'exists:lists_countries,id|required_with:passeport_number', 'passeport_expire' => 'date|required_with:passeport_number', 'stay_type' => 'sometimes|required|in:work,companion,tourism,non_resident', 'national_id' => 'required|unique:registrations,national_id,NULL,id,registration_period_id,' . $period_id . '', 'contact_region' => '', 'contact_postalbox' => 'required|max:255', 'degrees.*.degree_country_id' => 'required|exists:lists_countries,id', 'birth_country_id' => 'required|exists:lists_countries,id', 'nationality_country_id' => 'sometimes|required|exists:lists_countries,id', 'nationality_city_id' => 'sometimes|required|exists:lists_cities,id', 'nationality_state_id' => 'sometimes|required|exists:lists_states,id', 'contact_country_id' => 'required|exists:lists_countries,id', 'contact_city_id' => 'sometimes|required|exists:lists_cities,id', 'contact_state_id' => 'sometimes|required|exists:lists_states,id', 'contact_email' => 'required|unique:registrations,contact_email,NULL,id,registration_period_id,' . $period_id . '|max:255', 'contact_mobile' => 'required|numeric', 'degrees.*.degree_graduation_year' => 'required|numeric', 'contact_phone' => 'numeric', 'contact_fax' => 'numeric', 'degrees.*.degree_speciality' => 'required', 'degrees.*.degree_institution' => 'required', 'degrees.*.degree_score' => 'required', 'social_status' => 'required|in:' . $social_status, 'social_job_status' => 'required', 'social_job' => 'required_if:social_job_status,employed', 'social_job_start' => 'required_if:social_job_status,employed', 'social_experience' => 'required_if:social_job_status,employed', 'social_job_employer' => 'required_if:social_job_status,employed', 'social_job_country_id' => 'required_if:social_job_status,employed|exists:lists_countries,id', 'social_job_city_id' => 'required_if:social_job_status,employed|exists:lists_cities,id', 'health_status' => 'in:0,1|required', 'health_disabled_type' => 'required_if:health_status,disabled', 'health_disabled_size' => 'required_if:health_status,disabled', 'computer_skills' => 'in:' . $skill_levels, 'internet_skills' => 'in:' . $skill_levels, 'internet_link' => '', 'cyber_cafe' => '', 'computer_availability' => '']; }
public function index() { $period = Period::current()->select('id', 'start_at', 'finish_at')->first(); try { $reader = new Reader(storage_path('app/GeoLite2-Country.mmdb')); $record = $reader->country($request->ip()); $country = $record->country->isoCode; } catch (Exception $e) { $country = 'OM'; } if ($country == 'OM' && $period && app()->environment() !== 'local' && !in_array(app()->ip(), ['188.135.49.50'])) { $period = new StdClass(); } return response()->json($period, 200, [], JSON_NUMERIC_CHECK); }
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', 'لم يتم تسجيل طلبك ، المرجو التواصل مع الدعم الفني للمزيد من المعلومات'); } }
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', 'لم يتم تسجيل طلبك ، المرجو التواصل مع الدعم الفني للمزيد من المعلومات'); } }
public function pass(Request $request) { $steps = Step::pluck('name', 'id')->toArray(); $periods = Period::pluck('name', 'id')->toArray(); $current_period = Period::current()->first(); $registration_count = Registration::orderBy('id', 'desc'); $registration_gender = Registration::groupBy('gender'); $registration_specialty = Registration::groupBy('academystructure_specialty_id'); $registration_country = Registration::groupBy('contact_country_id'); $registration_step = Registration::groupBy('registration_step_id'); if (request('step_id')) { $registration_count->whereHas('histories', function ($query) { $query->where('registration_step_id', '=', request('step_id')); }); $registration_gender->whereHas('histories', function ($query) { $query->where('registration_step_id', '=', request('step_id')); }); $registration_specialty->whereHas('histories', function ($query) { $query->where('registration_step_id', '=', request('step_id')); }); $registration_country->whereHas('histories', function ($query) { $query->where('registration_step_id', '=', request('step_id')); }); $registration_step->whereHas('histories', function ($query) { $query->where('registration_step_id', '=', request('step_id')); }); } if (request('period_id')) { $registration_count->where('registration_period_id', request('period_id')); $registration_gender->where('registration_period_id', request('period_id')); $registration_specialty->where('registration_period_id', request('period_id')); $registration_country->where('registration_period_id', request('period_id')); $registration_step->where('registration_period_id', request('period_id')); } $registration_count = $registration_count->count(); $registration_gender = $registration_gender->select('gender', DB::raw('count(*) as total'))->orderBy('total', 'desc')->get()->toArray(); $registration_specialty = $registration_specialty->select('academystructure_specialty_id as specialty', DB::raw('count(*) as total'))->orderBy('total', 'desc')->get()->toArray(); $registration_country = $registration_country->select('contact_country_id as country', DB::raw('count(*) as total'))->orderBy('total', 'desc')->get()->toArray(); $registration_step = $registration_step->select('registration_step_id as step', DB::raw('count(*) as total'))->orderBy('total', 'desc')->get()->toArray(); $steps = Step::pluck('name', 'id')->toArray(); $periods = Period::pluck('name', 'id')->toArray(); $current_period = Period::current()->first(); $specialties = Specialty::pluck('name', 'id')->toArray(); $countries = Country::pluck('name', 'id')->toArray(); return view('registration::reports.pass', compact('steps', 'periods', 'current_period', 'specialties', 'countries', 'registration_gender', 'registration_specialty', 'registration_country', 'registration_step', 'registration_count')); }
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); }