コード例 #1
0
ファイル: routes.php プロジェクト: bheftye/ceeacce_web
Route::group(['middleware' => 'auth'], function () {
    Route::get('dashboard', function () {
        return view('dashboard');
    });
    Route::get('plans', function () {
        return view('plan/index')->with('plans', \ceeacce\Plan::all());
    });
    Route::get('plan/{id}', function ($id) {
        return view('plan/plan')->with('plan', \ceeacce\Plan::find($id));
    });
    Route::get('students', function () {
        $defaultPagination = 20;
        return view('student/index')->with(['students' => \ceeacce\Student::orderBy('last_name_p', 'asc')->paginate($defaultPagination), 'campuses' => \ceeacce\Campus::all()]);
    });
    Route::get('student/{id}', function ($id) {
        return view('student/student')->with(['student' => \ceeacce\Student::find($id), 'plans' => \ceeacce\Plan::all(), 'campuses' => \ceeacce\Campus::all()]);
    });
    Route::get('campuses', function () {
        return view('campus/index')->with('campuses', \ceeacce\Campus::all());
    });
    Route::get('campus/{id}', function ($id) {
        return view('campus/campus')->with('campus', \ceeacce\Campus::find($id));
    });
    Route::post('student/import', 'Student\\StudentController@import');
    Route::post('student/import/grades', 'Student\\StudentController@importGrades');
    Route::post('students', function (\Illuminate\Http\Request $request) {
        $defaultPagination = 20;
        $searchString = $request->search;
        return view('student/index')->with(['students' => \ceeacce\Student::where('name', 'like', $searchString)->orWhere('last_name_p', 'like', $searchString)->orWhere('last_name_m', 'like', $searchString)->orderBy('last_name_p', 'asc')->paginate($defaultPagination), 'campuses' => \ceeacce\Campus::all()]);
    });
    Route::post('student/save', 'Student\\StudentController@save');
コード例 #2
0
 /**
  * Method that saves/updates the Studen info.
  */
 protected function save(Request $request)
 {
     $data = $request->only(['clv', 'id', 'name', 'last_name_p', 'last_name_m', 'curp', 'email', 'birthday', 'year']);
     if ($data['id'] != 0) {
         $student = Student::find($data['id']);
     } else {
         $student = new Student();
     }
     $student->clv = $data['clv'];
     $student->name = $data['name'];
     $student->last_name_p = $data['last_name_p'];
     $student->last_name_m = $data['last_name_m'];
     $student->curp = $data['curp'];
     $student->email = $data['email'];
     $student->birthday = $data['birthday'];
     $student->year = $data['year'];
     if ($student->save()) {
         return redirect('student/' . $student->id)->with(['success' => 'true']);
     }
     return redirect('student/' . $student->id)->withInput($request)->with(['success' => 'warning']);
 }