public function orderlist(Request $request) { $equal_order_model = new Equal(); $equal_orders = $equal_order_model->where('semester_id', semester()->id)->with('student'); if (request('order_state')) { $equal_orders->where('state', request('order_state')); } if (request('student_name')) { $equal_orders->whereHas('student', function ($query) { $query->where('name', 'like', "%" . request('student_name') . "%"); }); } if (request('semester_id')) { $equal_orders->where('semester_id', request('semester_id')); } if (request('student_code')) { $equal_orders->whereHas('student', function ($query) { $query->where('username', 'like', "%" . request('student_code') . "%"); }); } $per_page = request('per_page') ? request('per_page') : 30; $equal_orders = $equal_orders->paginate($per_page); $equal_orders->appends($request->except("page")); //get all states for search $states = array_flatten(config('orders.equal_states')); $states = array_combine($states, $states); $semesters = Semester::select('academycycle_semesters.id', DB::raw('CONCAT(academycycle_semesters.name ,"-", ay.name ) as name '))->join('academycycle_years as ay', 'academycycle_semesters.academycycle_year_id', '=', 'ay.id')->pluck('name', 'id')->toArray(); return view('orders::equal.list', compact('equal_orders', 'states', 'semesters')); }
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'); } }