/** * @param $data */ protected function handleData($data) { $this->data = $data; $modelValues = $this->data; // If it is not an Eloquent instance just ignore modelValues if (is_a($modelValues, Collection::class)) { $modelValues = null; } View::share('fields', $this->modelSettings->toForm($modelValues)); View::share('data', $this->data); }
/** * Persist the data. */ public function persist() { $data = $this->getData(); $data = $this->applyBeforeHook($this->modelSettings->withValues($data)->toForm()); $data = $this->serializeForm($data); if ($this->isUpdating()) { $result = $this->currentModel->update($data); } else { $result = $this->currentModel->create($data); } return $this->applyAfterHook($result); }