/** * @param string $table * @param integer $id * */ protected function register($table, $id = null) { $this->buildInstances($table); $inputs = $this->service->getRegisterValues(Input::all()); $rules = $this->columns->getValidateRules(); $validator = Validator::make($inputs, $rules->toArray()); if ($validator->fails()) { return Redirect::to($this->getUrl('form', $table, $id))->withErrors($validator->errors())->withInput(); } try { $this->service->register($inputs, $id); if ($id) { $text = 'updated'; } else { $text = 'created'; } $message = ['type' => 'success', 'text' => $text]; return Redirect::to($this->getUrl('index', $table))->with('message', $message); } catch (Exception $e) { $message = ['type' => 'danger', 'text' => 'error']; return Redirect::to(Request::getUri())->with('message', $message)->withInput(); } }
/** * @param Column $column * @return ListView */ public function removeColumn(Column $column) : self { $this->columns->removeElement($column); return $this; }