/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(saveTeacherRequest $request) { $request->merge(array('remaining_credit' => $request->input('assigned_credit'))); // Set remaining credit equal to assigned credit $teacher = new Teacher($request->except(['department', 'designation'])); $department = Department::where('name', $request->input('department'))->first(); $designation = Designation::where('name', $request->input('designation'))->first(); $teacher->department()->associate($department); $teacher->designation()->associate($designation); $teacher->save(); $teacher_request = new UserRequestHandle('Teacher', $request->input('email')); $teacher_request->save(); $request->session()->flash('status', 'Teacher was saved successful!'); return back(); }
/** * Store a newly created resource in storage. * @param RegisterStudentRequest $request * @return \Illuminate\Http\RedirectResponse */ public function store(RegisterStudentRequest $request) { $student = new Student($request->except(['department_code'])); $date = strtotime($request->input('current_date')); $student->current_date = date('d/m/Y', $date); // Changed string date to Date format $department = Department::where('code', $request->input('department_code'))->first(); $student->registration_no = $department->name . '-' . date('Y', $date) . '-' . sprintf("%03d", $department->students->count() + 1); // Create Student registration no. $student->department()->associate($department); $student->save(); $student_request = new UserRequestHandle('Student', $request->input('email')); $student_request->save(); $request->session()->flash('status', 'Student registration was successful!'); return back(); }