/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); $tr = new TranslateClient('en', 'ar'); $countries = json_decode(File::get(__DIR__ . "/u_countries.json"), true); Country::whereNotNull('id')->delete(); City::whereNotNull('id')->delete(); State::whereNotNull('id')->delete(); foreach ($countries as $country) { $name = $tr->translate($country['name']); //$country['name']; $newCountry = Country::create(['name' => $name, 'iso_3166_2' => $country['iso_3166_2'], 'calling_code' => $country['calling_code']]); } $countries = Country::get(); foreach ($countries as $country) { $new_cities = []; $new_states = []; $states = DB::connection('tests')->table('states')->select('states.*')->join('countries', function ($j) use($country) { $j->on('countries.id', '=', 'states.country_id')->where('countries.sortname', '=', $country->iso_3166_2); })->get(); foreach ($states as $state) { $new_cities[] = ['id' => $state->id, 'name' => $tr->translate($state->name), 'country_id' => $country->id]; $cities = DB::connection('tests')->table('cities')->select('cities.*')->join('states', function ($j) use($state) { $j->on('states.id', '=', 'cities.state_id')->where('states.id', '=', $state->id); })->get(); foreach ($cities as $city) { $new_states[] = ['id' => $city->id, 'name' => $tr->translate($city->name), 'city_id' => $state->id]; } } DB::table('lists_cities')->insert($new_cities); DB::table('lists_states')->insert($new_states); } }
public function index(Country $country, Request $request) { $country->load('cities'); $cities = $country->cities; if ($request->has('name')) { $cities = City::where('name', 'LIKE', "%" . $request->input('name') . "%")->paginate(20); } return view('lists::cities.index', compact('cities', 'country')); }
public function deleteBulk(Request $req, Country $CountryModel) { if (!$req->has('table_records')) { return redirect()->route('countries.index'); } $ids = $req->input('table_records'); $CountryModel->destroy($ids); return redirect()->route('countries.index')->with('success', trans('lists::countries.delete_bulk_success')); }
public function index(Registration $Registration) { $registrations = $Registration->with('step', 'period', 'period.year')->orderBy('id', 'desc'); $steps = RegistrationStep::lists('name', 'id')->toArray(); $countries = Country::lists('name', 'id')->toArray(); $search_fields = ['gender', 'registration_step_id', 'nationality_type', 'contact_country_id', 'social_status', 'social_job']; $years = AcademycycleYear::lists('name', 'id')->toArray(); $genders = config('registration.genders'); foreach ($search_fields as $field) { if (request($field)) { $registrations->whereIn($field, request($field)); } } if (request('academycycle_year')) { $registrations->whereHas('period', function ($query) { $query->whereHas('year', function ($query2) { $query2->whereIn('id', request('academycycle_year')); }); }); } if (request('national_id')) { $registrations->where('national_id', request('national_id')); } if (request('contact_email')) { $registrations->where('contact_email', request('contact_email')); } $registrations = $registrations->paginate(50); return view('registration::registrations.index', compact('registrations', 'steps', 'countries', 'years')); }
public function form(RegistrationPeriod $PeriodModel, Country $CountryModel, Specialty $Specialty, Registration $Registration, RegistrationType $type) { $registration = $Registration->with('degrees', 'contactcountry', 'contactcity', 'contactcity.states', 'birthcountry', 'nationalitycity', 'jobcountry', 'jobcountry.cities')->find(registrar()->id); $specialties = $Specialty->pluck('name', 'id')->toArray(); $registration_types = $type->pluck('title', 'id')->toArray(); $countries = $CountryModel->all(); $countries_list = ["" => ""] + $countries->pluck('name', 'id')->toArray(); $codes_list = ["" => ""] + $countries->pluck('calling_code', 'id')->toArray(); $stay_types = config('registration.stay_types'); $social_status = ["" => ""] + config('registration.social_status'); $social_job_status = ["" => "", 'unemployed' => 'بدون عمل', 'employed' => 'أعمل', 'retired' => 'متقاعد']; $years_list = ["" => ""] + array_combine(range(date("Y") - 80, date('Y')), range(date("Y") - 80, date('Y'))); $computer_skills = ["" => "", 'very_low' => 'ضعيف جدا', 'low' => 'ضعيف', 'good' => 'جيد', 'great' => 'جيد جدا', 'excellent' => 'ممتاز']; $social_job_types = ["" => "", 'government' => 'عام', 'private' => 'خاص', 'free' => 'حر']; $social_jobs = ["" => "", 'unemployed' => 'بدون عمل', 'employed' => 'أعمل', 'retired' => 'متقاعد']; $references = ["" => "", 'iiswebsite' => 'موقع كلية العلوم الشرعية', 'iisewebsite' => 'موقع مركز التعليم عن بعد', 'iisfriend' => 'صديق يدرس بالكلية', 'iisefriend' => 'صديق يدرس بمركز التعليم عن بعد', 'other' => 'أخرى']; return view('registration::registrar.form', compact('registration', 'specialties', 'registration_types', 'period', 'years_list', 'countries', 'stay_types', 'countries_list', 'references', 'computer_skills', 'codes_list', 'social_job_types', 'social_status', 'social_jobs')); }
public function index(Request $request) { $per_page = request('per_page', 20); $students = $this->prepQuery($request->all()); $students = $students->paginate($per_page); $students->appends($request->except('page')); $year_term = Year::join('academystructure_terms', 'academystructure_years.id', '=', 'academystructure_terms.year_id')->select(\DB::raw('CONCAT(academystructure_years.name, "-", academystructure_terms.name) as name, academystructure_terms.id as tid'))->groupBy('academystructure_terms.name', 'academystructure_years.name')->orderBy('academystructure_terms.id')->pluck('name', 'tid')->toArray(); $spec_id = Specialty::pluck('name', 'id')->toArray(); $county = Country::pluck('name', 'id')->toArray(); $city = City::pluck('name', 'id')->toArray(); // return $students->pluck('sps'); return view('students::students.index', compact('students', 'year_term', 'spec_id', 'county', 'city')); }
public function apply(RegistrationPeriod $PeriodModel, Country $CountryModel, Specialty $Specialty, RegistrationType $type) { $period = $PeriodModel->orderBy('id', 'desc')->with('year')->current()->first(); if (!$period) { return redirect()->route('welcome'); } $specialties = $Specialty->lists('name', 'id'); $registration_types = $type->lists('title', 'id')->toArray(); $countries = $CountryModel->all(); $countries_list = ["" => ""] + $countries->lists('name', 'id')->toArray(); $codes_list = ["" => ""] + $countries->lists('calling_code', 'id')->toArray(); $stay_types = config('registration.stay_types'); $social_status = ["" => ""] + config('registration.social_status'); $social_job_status = ["" => "", 'unemployed' => 'بدون عمل', 'employed' => 'أعمل', 'retired' => 'متقاعد']; $years_list = ["" => ""] + array_combine(range(date("Y") - 80, date('Y')), range(date("Y") - 80, date('Y'))); $computer_skills = ["" => "", 'excellent' => 'ممتاز', 'great' => 'جيد جدا', 'very_low' => 'ضعيف جدا', 'low' => 'ضعيف', 'good' => 'جيد']; $social_job_types = ["" => "", 'government' => 'عام', 'private' => 'خاص', 'free' => 'حر']; $social_jobs = ["" => "", 'unemployed' => 'بدون عمل', 'employed' => 'أعمل', 'retired' => 'متقاعد']; $references = ["" => "", 'iiswebsite' => 'موقع كلية العلوم الشرعية', 'iisewebsite' => 'موقع مركز التعليم عن بعد', 'iisfriend' => 'صديق يدرس بالكلية', 'iisefriend' => 'صديق يدرس بمركز التعليم عن بعد', 'other' => 'أخرى']; $period = $PeriodModel->orderBy('id', 'desc')->with('year')->where(function ($sql) { $sql->where('start_at', '<=', date('Y-m-d'))->where('finish_at', '>=', date('Y-m-d')); })->first(); return view('registration::registrar.apply', compact('years_list', 'specialties', 'registration_types', 'period', 'countries', 'stay_types', 'countries_list', 'references', 'computer_skills', 'codes_list', 'social_job_types', 'social_status', 'social_jobs')); }
/** * Register the service provider. * * @return void */ public function register() { //City City::created(function ($city) { UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_city', 'reference_id' => $city->id]); }); City::updated(function ($city) { UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_city', 'reference_id' => $city->id]); }); City::deleted(function ($city) { UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_city', 'reference_id' => $city->id]); }); //Country Country::created(function ($country) { UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_country', 'reference_id' => $country->id]); }); Country::updated(function ($country) { UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_country', 'reference_id' => $country->id]); }); Country::deleted(function ($country) { UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_country', 'reference_id' => $country->id]); }); //Region Region::created(function ($region) { UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_region', 'reference_id' => $region->id]); }); Region::updated(function ($region) { UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_region', 'reference_id' => $region->id]); }); Region::deleted(function ($region) { UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_region', 'reference_id' => $region->id]); }); //State State::created(function ($state) { UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_state', 'reference_id' => $state->id]); }); State::updated(function ($state) { UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_state', 'reference_id' => $state->id]); }); State::deleted(function ($state) { UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'Lists_state', 'reference_id' => $state->id]); }); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); $countries = json_decode(File::get(__DIR__ . "/countries.json"), true); $cities = ['OM' => [['name' => 'مسقط', 'states' => [['name' => 'الخوير']]], ['name' => 'البريمي'], ['name' => 'الباطنة شمال'], ['name' => 'الباطنة جنوب'], ['name' => 'الظاهرة'], ['name' => 'الداخلية '], ['name' => 'الشرقية شمال'], ['name' => 'الشرقية جنوب'], ['name' => 'الوسطى'], ['name' => 'ظفار'], ['name' => 'مسندم']]]; $permissions = [['name' => 'اضافة دول', 'slug' => 'create.countries', 'module' => 'lists'], ['name' => 'تعدل دول', 'slug' => 'edit.countries', 'module' => 'lists'], ['name' => 'حذف دول', 'slug' => 'delete.countries', 'module' => 'lists'], ['name' => 'مشاهدة الدولة', 'slug' => 'view.countries', 'module' => 'lists'], ['name' => 'اضافة مدن', 'slug' => 'create.cities', 'module' => 'lists'], ['name' => 'تعدل مدن', 'slug' => 'edit.cities', 'module' => 'lists'], ['name' => 'حذف مدن', 'slug' => 'delete.cities', 'module' => 'lists'], ['name' => 'مشاهدة المدن', 'slug' => 'view.cities', 'module' => 'lists'], ['name' => 'اضافة محافظة', 'slug' => 'create.states', 'module' => 'lists'], ['name' => 'تعدل محافظة', 'slug' => 'edit.states', 'module' => 'lists'], ['name' => 'حذف محافظة', 'slug' => 'delete.states', 'module' => 'lists'], ['name' => 'مشاهدة المحافظات', 'slug' => 'view.states', 'module' => 'lists']]; $slugs = array_map(function ($ar) { return $ar['slug']; }, $permissions); Permission::whereIn('slug', $slugs)->delete(); Country::whereNotNull('id')->delete(); City::whereNotNull('id')->delete(); State::whereNotNull('id')->delete(); $users = User::all(); foreach ($permissions as $permission) { $perm = Permission::create($permission); foreach ($users as $user) { $user->attachPermission($perm); } } $tr = new TranslateClient('en', 'ar'); foreach ($countries as $country) { $name = $country['name']; //$tr->translate($country['name']); $newCountry = Country::create(['name' => $name, 'calling_code' => $country['calling_code']]); if (isset($cities[$country['iso_3166_2']])) { foreach ($cities[$country['iso_3166_2']] as $city) { $newCity = City::create(['name' => $city['name'], 'country_id' => $newCountry->id]); if (isset($city['states'])) { foreach ($city['states'] as $state) { State::create(['name' => $state['name'], 'city_id' => $newCity->id]); } } } } } }
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 registerEvents() { City::creating(function ($city) { $city->created_by = user() ? user()->id : 1; }); Country::creating(function ($country) { $country->created_by = user() ? user()->id : 1; }); }
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 index() { $countries = Country::orderBy('name', 'asc')->selectRaw('id as value, name as text')->get()->toArray(); return response()->json($countries, 200, [], JSON_NUMERIC_CHECK); }
public function index(Country $country) { $country->load('cities'); $cities = $country->cities; return view('lists::cities.index', compact('cities', 'country')); }
public function create($event_type, $type, SemesterEvent $SemesterEvent) { $current_semester_id = semester()->id; $student_id = student()->id; $semesters = Semester::with('year')->get(); $semester_id = []; /////////////////////////////////////delay///////////////////////////// if ($event_type == 'delay') { // get delay order period //dd($semesters); $delay_semester_events = $SemesterEvent->where('semester_id', '=', $current_semester_id)->whereHas('event_type', function ($query) { $query->where('academycycle_semesterevent_types.category', 'delay'); })->first(); // get delay order for student in current semeter if exist and not refuse or cancel $delayOrders = new DelayOrders(); $student_delay_order = $delayOrders->where('semester_id', '=', $current_semester_id)->where('student_id', '=', $student_id)->whereNotIn('state', array('الغاء بناء على طلب الطالب', 'الغاء لعدم الاستكمال', 'رفض'))->first(); if ($student_delay_order and $type == 0) { return redirect()->route('student.orders.list', $event_type); } else { //check if period available if ($type == 0) { foreach ($semesters as $semester) { if ($semester->active == 1) { $semester_id[$semester->id] = $semester->year->name . " -- " . $semester->name; } } return view('orders::delay.create', compact('semester_id')); } elseif ($type == '1') { // bring all semester foreach ($semesters as $semester) { $semester_id[$semester->id] = $semester->year->name . " -- " . $semester->name; } return view('orders::delay.create', compact('semester_id')); } else { return redirect()->route('orders.index'); } } //////////////////////////////////////withdraw///////////////////////////// } elseif ($event_type == 'withdraw') { // get delay order period $withdraw_semester_events = $SemesterEvent->where('semester_id', '=', $current_semester_id)->whereHas('event_type', function ($query) { $query->where('academycycle_semesterevent_types.category', 'withdraw'); })->first(); // get withdraw order for student in current semeter if exist and not refuse or cancel $withdrawOrders = new WithdrawOrders(); $student_withdraw_order = $withdrawOrders->where('semester_id', '=', $current_semester_id)->where('student_id', '=', $student_id)->whereNotIn('state', array('الغاء بناء على طلب الطالب', 'الغاء لعدم الاستكمال', 'رفض'))->first(); if ($student_withdraw_order) { return redirect()->route('student.orders.list', $event_type); } else { //check if period available if ($type == 0) { foreach ($semesters as $semester) { if ($semester->active == 1) { $semester_id[$semester->id] = $semester->year->name . " -- " . $semester->name; } } return view('orders::withdraw.create', compact('semester_id')); } elseif ($type == '1') { // all semester foreach ($semesters as $semester) { $semester_id[$semester->id] = $semester->year->name . " -- " . $semester->name; } return view('orders::withdraw.create', compact('semester_id')); } else { return redirect()->route('orders.index'); } } /////////////////////////////////////Equal///////////////////////////// } elseif ($event_type == 'equal_subject') { // get equal_subject order period $equal_subject_semester_events = $SemesterEvent->where('semester_id', '=', $current_semester_id)->whereHas('event_type', function ($query) { $query->where('academycycle_semesterevent_types.category', 'equal_subject'); })->first(); // get delay order for student in current semeter if exist and not review $equalOrders = new EqualOrders(); $student_equal_subject_order = $equalOrders->where('semester_id', '=', $current_semester_id)->where('student_id', '=', $student_id)->whereNotIn('state', array('الغاء بناء على طلب الطالب', 'الغاء لعدم الاستكمال', 'رفض', 'مكتمل'))->first(); if ($student_equal_subject_order) { return redirect()->route('student.orders.list', $event_type); } else { //check if period available //if($equal_subject_semester_events->start_at <= date("Y-m-d") && $equal_subject_semester_events->finish_at >= date("Y-m-d")){ $country_list = Country::pluck('name', 'id')->toArray(); return view('orders::equal.create', compact('country_list')); //}else{ //return redirect()->route('orders.index'); //} } ///////////////////////////////////////////excuse///////////////////////////// } elseif ($event_type == 'excuse') { // same same return view('orders::delay.excuse'); } }
public function deleteBulk(Request $req, Country $CountryModel) { $submit = $req->input('submit'); if (!$req->has('table_records')) { return redirect()->route('countries.index'); } $ids = $req->input('table_records'); switch ($submit) { case 'delete': $CountryModel->destroy($ids); return redirect()->route('countries.index')->with('success', trans('lists::countries.delete_bulk_success')); break; case 'activate': Country::where('status', 0)->update(['status' => 1]); Country::where('id', 1)->update(['status' => 0]); $message = 'تم تفعيل الكل'; return redirect()->back()->with('success', $message); break; case 'notactivate': Country::where('status', 1)->update(['status' => 0]); Country::where('id', 1)->update(['status' => 0]); $message = 'تم إلغاء تفعيل الكل'; return redirect()->back()->with('success', $message); break; default: # code... break; } }