public function index() { $years = SchoolYear::all(); $current_year = $years->pop(); $current_handbook = $current_year->course_handbook; $handbooks = CourseHandbook::all(); return view('configuracion.anos-lectivos')->with(compact(['years', 'current_year', 'current_handbook', 'handbooks'])); }
/** * Run the database seeds. * * @return void */ public function run() { $carbon = Carbon::now('America/Lima'); // Current year $year = $carbon->year; // Getting the current school year $schoolYear = SchoolYear::all()->last(); // Calculating the middle date $middle = clone $schoolYear->start; $middle->addMonths(6); // First period of the current school year Period::create(['school_year_id' => $schoolYear->id, 'name' => $year . '-I', 'start' => $schoolYear->start, 'end' => $middle]); // Last period of the current school year Period::create(['school_year_id' => $schoolYear->id, 'name' => $year . '-II', 'start' => $middle->addDay(), 'end' => $schoolYear->end]); }