Ejemplo n.º 1
0
     }
 });
 // 執行編輯班級
 Route::post('/update_classes/{classesId}/{yearId}', function ($classesId, $yearId) {
     $validator = FormValidator::classes(Input::all());
     if ($validator->fails()) {
         return Redirect::to('/class_year/view_year/' . $yearId)->withInput()->withErrors($validator)->with('message', '輸入錯誤,請檢查');
     } else {
         $data = Input::all();
         $year = Classes::find($classesId);
         if ($year->update($data)) {
             $message = '更新《' . $data['classes_name'] . '》完成';
         } else {
             $message = '資料寫入錯誤';
         }
         Classes::syncTeacher();
         return Redirect::to('/class_year/view_year/' . $yearId)->with('message', $message);
     }
 });
 // 執行刪除班級
 Route::get('/delete_classes/{classesId}/{yearId}', function ($classesId, $yearId) {
     $classes = Classes::find($classesId);
     $message = '刪除《' . $classes->classes_name . '》完成';
     $classes->delete();
     return Redirect::to('/class_year/view_year/' . $yearId)->with('message', $message);
 });
 // 執行刪除年級
 Route::get('/delete_year/{yearId}', function ($yearId) {
     $year = Year::find($yearId);
     $message = '刪除《' . $year->year_name . '》完成';
     $year->delete();