コード例 #1
0
 public function store(Semester $Semester, validationRequest $request)
 {
     $yid = $request->academycycle_year_id;
     $input = $request->except('active');
     $Semester->fill($input);
     $Semester->active = $request->has('active') ? request('active') : 0;
     if ($Semester->active) {
         //update set all semester not active
         $all_semesters = new Semester();
         $all_semesters->update(['active' => 0]);
     }
     $Semester->save();
     return redirect()->route('ac.semesters.index', [$yid]);
 }
コード例 #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     if (Semester::count() > 0) {
         return;
     }
     Semester::where('id', '>', 0)->delete();
     Year::where('id', '>', 0)->delete();
     $years = DB::connection('old')->table('eduyears')->get();
     foreach ($years as $year) {
         $new_year = new Year();
         //new_year->id = $year->sub_id;
         $new_year->name = $year->eyear_title;
         //$new_year->start_at = $year->eyear_created ;
         //$new_year->finish_at = $year->eyear_created + 1 year;
         $new_year->save();
     }
     $this->command->info('year table seeded!');
     $sems = DB::connection('old')->table('semesters')->get();
     foreach ($sems as $sem) {
         $new_semester = new Semester();
         $new_semester->id = $sem->sem_id;
         $new_semester->name = $sem->sem_name;
         // $new_semester->start_at = $sem->sem_from ;
         // $new_semester->finish_at = $sem->sem_to;
         $new_semester->active = $sem->sem_current;
         $new_semester->Academycycle_year_id = $sem->sem_eyearid;
         $term = '';
         if ($sem->sem_term == 1) {
             $term = 'first';
         }
         if ($sem->sem_term == 2) {
             $term = 'second';
         }
         if ($sem->sem_term == 3) {
             $term = 'summer';
         }
         $new_semester->order = $term;
         $new_semester->save();
     }
     $this->command->info('Semester table seeded!');
 }
コード例 #3
0
 public function store(ValidationRequest $request)
 {
     if (!$this->checkIntervalsConflict($request)) {
         return redirect()->back()->withInput()->with('warning', "خارج نطاق العام");
     }
     if ($this->checkIntervalsConflictSemester($request)) {
         return redirect()->back()->withInput()->with('warning', "يوجد فصل في نفس الفترة");
     }
     $input = $request->except('active');
     $semester = new Semester();
     $semester->fill($input);
     $semester->active = $request->has('active') ? request('active') : 0;
     if ($semester->active) {
         // only one semester can be active
         //update set all semester not active
         Semester::where('active', 1)->update(['active' => 0]);
     }
     $semester->save();
     if (request('submit') == 'save') {
         return redirect()->back()->with('success');
     } else {
         return redirect()->route('ac.semesters.index', [$semester->academycycle_year_id]);
     }
 }