/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Request $request, $id) { $this->validate($request, ['nickname' => 'required', 'content' => 'required']); if (Comment::where('id', $id)->update(Input::except(['_method', '_token']))) { return Redirect::to('admin/comments'); } else { return Redirec::back()->withInput()->withErrors("更新失败"); } }
*/ Route::filter('guest', function () { if (Auth::check()) { return Redirect::to('/'); } }); /* |-------------------------------------------------------------------------- | CSRF Protection Filter |-------------------------------------------------------------------------- | | The CSRF filter is responsible for protecting your application against | cross-site request forgery attacks. If this special token in a user | session does not match the one given in this request, we'll bail. | */ Route::filter('csrf', function () { if (Session::token() != Input::get('_token')) { throw new Illuminate\Session\TokenMismatchException(); } }); Route::filter('no_xhr', function () { if (Request::ajax()) { return Response::json("Bad request", 400); } }); Route::filter('only_xhr', function () { if (!Request::ajax()) { return Redirec::back()->with('notification:error', 'Access denied.'); } });