/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); $permissions = [['name' => 'تعدل طلب', 'slug' => 'edit.registration.registrations', 'module' => 'registration'], ['name' => 'حذف طلب', 'slug' => 'delete.registration.registrations', 'module' => 'registration'], ['name' => 'مشاهدة الطلبات', 'slug' => 'view.registration.registrations', 'module' => 'registration'], ['name' => 'اضافة مرحلة قبول تسجيل', 'slug' => 'create.registration.steps', 'module' => 'registration'], ['name' => 'تعدل مرحلة قبول تسجيل', 'slug' => 'edit.registration.steps', 'module' => 'registration'], ['name' => 'حذف مرحلة قبول تسجيل', 'slug' => 'delete.registration.steps', 'module' => 'registration'], ['name' => 'مشاهدة مراحل التسجيل', 'slug' => 'view.registration.steps', 'module' => 'registration'], ['name' => 'اضافة مستندات', 'slug' => 'create.registration.files', 'module' => 'registration'], ['name' => 'تعدل مستندات', 'slug' => 'edit.registration.files', 'module' => 'registration'], ['name' => 'حذف مستندات', 'slug' => 'delete.registration.files', 'module' => 'registration'], ['name' => 'مشاهدة المستندات', 'slug' => 'view.registration.files', 'module' => 'registration'], ['name' => 'اضافة فترة القبول', 'slug' => 'create.registration.periods', 'module' => 'registration'], ['name' => 'تعدل فترة القبول', 'slug' => 'edit.registration.periods', 'module' => 'registration'], ['name' => 'حذف فترة القبول', 'slug' => 'delete.registration.periods', 'module' => 'registration'], ['name' => 'مشاهدة فترات القبول', 'slug' => 'view.registration.periods', 'module' => 'registration'], ['name' => 'اضافة ملاحظة لمرحلة قبول', 'slug' => 'create.registration.notes', 'module' => 'registration'], ['name' => 'تعدل ملاحظة لمرحلة قبول', 'slug' => 'edit.registration.notes', 'module' => 'registration'], ['name' => 'حذف ملاحظة من مرحلة قبول', 'slug' => 'delete.registration.notes', 'module' => 'registration'], ['name' => 'مشاهدة ملاحظات مراحل القبول', 'slug' => 'view.registration.notes', 'module' => 'registration']]; $slugs = array_map(function ($ar) { return $ar['slug']; }, $permissions); Permission::whereIn('slug', $slugs)->delete(); $types = [['title' => 'دبلوم', 'code' => 'D'], ['title' => 'بكالوريوس', 'code' => 'B'], ['title' => 'تكميلي', 'code' => 'C']]; $period = ['start_at' => date('Y-m-d'), 'finish_at' => date("Y-m-d", strtotime('+1 month', strtotime(date('Y-m-d')))), 'code' => '161', 'academycycle_year_id' => '1']; $steps = [['name' => 'تم تقديم طلب', 'verify_email' => 1, 'email_template' => view('registration::steps.templates.verify_email')], ['name' => 'رفع الملفات', 'upload_files' => 1], ['name' => 'الغاء']]; RegistrationStep::whereNotNull('id')->delete(); foreach ($steps as $step) { RegistrationStep::create($step); } RegistrationPeriod::whereNotNull('id')->delete(); RegistrationPeriod::create($period); RegistrationType::whereNotNull('id')->delete(); foreach ($types as $type) { RegistrationType::create($type); } $users = User::all(); foreach ($permissions as $permission) { $perm = Permission::create($permission); foreach ($users as $user) { $user->attachPermission($perm); } } }
/** * 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']; }
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 checkOverlapingPeriods($period = null) { $periods = Period::where(function ($sql) { $sql->where('start_at', '<=', request('finish_at'))->where('finish_at', '>=', request('start_at')); }); if ($period) { $periods->whereNotIn('id', $period->id); } return $periods->count(); }
/** * 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 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 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); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); if (RegistrationStep::count()) { return; } $types = [['title' => 'دبلوم', 'code' => 'D'], ['title' => 'بكالوريوس', 'code' => 'B'], ['title' => 'تكميلي', 'code' => 'C']]; $period = ['start_at' => date('Y-m-d'), 'finish_at' => date("Y-m-d", strtotime('+1 month', strtotime(date('Y-m-d')))), 'code' => '161', 'academycycle_year_id' => '1']; $steps = [['name' => 'تم تقديم طلب', 'verify_email' => 1, 'email_template' => view('registration::steps.templates.verify_email')], ['name' => 'رفع الملفات', 'upload_files' => 1], ['name' => 'الغاء']]; RegistrationStep::whereNotNull('id')->delete(); foreach ($steps as $step) { RegistrationStep::create($step); } RegistrationPeriod::whereNotNull('id')->delete(); RegistrationPeriod::create($period); RegistrationType::whereNotNull('id')->delete(); foreach ($types as $type) { RegistrationType::create($type); } }
/** * Show the application login form for registrar. * * @return \Illuminate\Http\Response */ public function getRegLogin(RegistrationPeriod $PeriodModel) { // dd(bcrypt(123456)); $period = $PeriodModel->orderBy('id', 'desc')->with('year')->current()->first(); return view('auth.registrations.login', compact('period')); }
public function export(Request $request) { Excel::create('registrations', function ($excel) { $excel->sheet('registrations', function ($sheet) { $steps = RegistrationStep::pluck('name', 'id')->toArray(); $specialties = Specialty::pluck('name', 'id')->toArray(); $type = RegistrationType::pluck('title', 'id')->toArray(); $genders = config('registration.genders'); $countries = Country::pluck('name', 'id')->toArray(); $cities = City::pluck('name', 'id')->toArray(); $states = State::pluck('name', 'id')->toArray(); $years = AcademycycleYear::pluck('name', 'id')->toArray(); $registration_periods = RegistrationPeriod::pluck('name', 'id')->toArray(); $registrations = $this->prepQuery(request()->all())->get(); $sheet->loadView('registration::registrations.export', compact('registration_periods', 'registrations', 'steps', 'countries', 'years', 'specialties', 'type', 'genders', 'cities', 'states')); })->download('xlsx'); }); }
public function resendspec(Request $request) { $current_period = RegistrationPeriod::orWhere(function ($query) { $query->whereDate('start_at', '<=', date('Y-m-d')); $query->whereDate('finish_at', '>=', date('Y-m-d')); })->orWhereDate('finish_at', '<=', date('Y-m-d'))->orderBy('id', 'desc')->first(); if ($current_period) { if ($request->has('step_id')) { $registrations = Registration::where('registration_step_id', $request->input('step_id'))->where('registration_period_id', $current_period->id)->get(); foreach ($registrations as $registration) { $payload = ['send_to' => $registration->contact_email, 'send_to_name' => $registration->full_name, 'subject' => $request->input('email_subject'), 'data' => ['fullname' => $registration->full_name, 'template' => $request->input('email_template')]]; $message = $request->input('email_template'); $receivers = $registration->contact_mobile; $registrationId = $registration->id; $senderId = user()->id; if ($request->has('email_template')) { $this->dispatch(new SendRegistrationStepChangedEmail($payload)); } if ($request->has('sms_template')) { $this->dispatch(new SendRegistrationStepChangedSms($request->input('sms_template'), $receivers, $registrationId, $senderId)); } } } return redirect()->route('registration.steps.index')->with('success', trans('registration::steps.spec_send_success')); } else { return redirect()->route('registration.steps.index')->with('warning', trans('registration::steps.spec_send_fail')); } }
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); }
public function index(RegistrationPeriod $PeriodModel) { $period = $PeriodModel->orderBy('id', 'desc')->with('year')->current()->first(); $registration = registrar(); return view('registration::registrar.index', compact('period', 'registration')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(RegistrationPeriod $PeriodModel) { $period = $PeriodModel->orderBy('id', 'desc')->with('year')->current()->first(); return view('welcome', compact('period')); }