/** * Store a newly created resource in storage. * * @return Response */ public function store() { if (Auth::check()) { $data["inside_url"] = Config::get('app.inside_url'); $data["user"] = Session::get('user'); // Verifico si el usuario es un Webmaster if ($data["user"]->idrol == 1) { // Validate the info, create rules for the inputs $rules = array('nombre' => 'required|max:100|alpha_num_spaces|unique:dimensiones,nombre'); // Run the validation rules on the inputs from the form $validator = Validator::make(Input::all(), $rules); // If the validator fails, redirect back to the form if ($validator->fails()) { return Redirect::to('dimensiones/create')->withErrors($validator)->withInput(Input::all()); } else { $dimension = new Dimension(); $dimension->nombre = Input::get('nombre'); $dimension->save(); return Redirect::to('dimensiones/index')->with('message', 'Se registró correctamente la dimensión: ' . $dimension->nombre); } } else { return View::make('error/error', $data); } } else { return View::make('error/error', $data); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Dimension(); $model->nombre = $_POST['nombreDimension']; $model->id_empresa = $_POST['idEmpresaDimension']; $model->save(); $this->redirect(array('default/index')); }