/** * Store a newly created resource in storage. * * @return Response */ public function store() { // validate // read more on validation at http://laravel.com/docs/validation $rules = array('name' => 'required', 'quantity' => 'required|numeric'); $validator = Validator::make(Input::all(), $rules); // process the login if ($validator->fails()) { return Redirect::to('cars/create')->withErrors($validator)->withInput(Input::except('password')); } else { // store $cars = new Cars(); $cars->name = Input::get('name'); $cars->quantity = Input::get('quantity'); $cars->note = Input::get('note'); $cars->save(); // redirect Session::flash('message', 'Successfully created cars!'); return Redirect::to('cars'); } }