get(); $subjects_grouped = $subjects->groupBy($groupBy); $rooms = Room::all(); $weekdays = ['Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota', 'Niedziela']; // $types = ['Lecture', 'Excercises', 'Labs', 'Other']; $defaultTime = date("H:i"); if(date('w')-1 < 0 ) { $defaultWeekday = $weekdays[6]; } else { $defaultWeekday = "Poniedziałek";//$weekdays[date('w') - 1]; } return view('user.user_subjects', ['subjects' => $subjects, 'weekdays' => $weekdays, 'subjects_grouped' => $subjects_grouped, 'grouped_by' => $groupBy, 'defaultTime' => $defaultTime, 'defaultWeekday' => $defaultWeekday, 'rooms' => $rooms]); } public function add_subject(Request $request) { $name = $request->input('name'); // $type = $request->input('type'); $weekday = $request->input('weekday'); $time = $request->input('time'); $room_id = $request->input('room_id'); $user_id_n = Auth::id(); Subject::create([ 'name' => $name, // 'type' => $type, 'weekday'=> $weekday, 'time' => $time, 'room_id' => $room_id, 'user_id' => $user_id_n ]); return redirect(route('user_subjects')); } public function delete_subject($subject_id) { Subject::find($subject_id)->delete(); return redirect(route('user_subjects')); } public function edit_subject($subject_id) { Subject::find($subject_id); return redirect(route('user_subjects')); } }