public function addAction() { // create a new model instance //////////////////////////////////////////////////////////// $xi = 0; if (Input::has('index')) { $xi = Input::get("index"); } ///////////////////////////////////////////////////////////// $Objnew = new Compra(); if ($Objnew->isPosted()) { $new = Input::all(); // attempt validation if ($Objnew->validate($xi, $new, 1)) { $object = Compra::create([Compra::$FieldsName[Compra::$FieldsOrderCreate['1']] => Input::get($this->FieldsCreate['1']['name'] . "0"), Compra::$FieldsName[Compra::$FieldsOrderCreate['2']] => Input::get($this->FieldsCreate['2']['name'] . $xi), Compra::$FieldsName[Compra::$FieldsOrderCreate['3']] => Input::get($this->FieldsCreate['3']['name'] . $xi), Compra::$FieldsName[Compra::$FieldsOrderCreate['4']] => Input::get($this->FieldsCreate['4']['name'] . $xi), Compra::$FieldsName[Compra::$FieldsOrderCreate['5']] => Input::get($this->FieldsCreate['5']['name'] . $xi), Compra::$FieldsName[Compra::$FieldsOrderCreate['6']] => Input::get($this->FieldsCreate['6']['name'] . $xi), Compra::$FieldsName[Compra::$FieldsOrderCreate['7']] => Input::get($this->FieldsCreate['7']['name'] . "0")]); return Response::json(['success' => true, 'iddelrow' => Input::get('index')]); } else { $this->errors = $Objnew->errors(); $this->addrow = $this->addrowAction(); return Response::json(['success' => false, 'error' => $this->errors->toArray()]); } } $this->addrow = $this->addrowAction(); $object; $xi = 0; return View::make($this->routeAdd, ["row" => $this->addrow, "FieldsCreate" => $this->FieldsCreate, "module" => $this->module, "key" => $this->key]); }