示例#1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //TODO: validation should be done in the MODEL not in the controller :)
     $data = Input::all();
     $rules = ['name' => 'required'];
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         return Redirect('/authors/create')->withErrors($validator)->withInput();
     } else {
         echo "data is ok";
         Author::saveAuthor($data);
         return Redirect('/authors');
     }
 }