public function store() { $post = Input::all(); unset($post['_token']); if (isset($post['id']) && $post['id'] !== '') { $model = Curso::find($post['id']); } else { $model = new Curso(); } if (!$model->validate($post)) { return Redirect::to('curso/create')->withInput($post)->withErrors($model->errors); } else { $model->tipo = $post['tipo']; $model->nome = $post['nome']; if ($model->save()) { Session::flash('success', 'Curso cadastrado com sucesso!'); return Redirect::to('curso/' . $model->id); } } }