public function createOrUpdate($values, $id = null) { /** @var \App\Models\Table $model */ $model = $id ? $this->read($id) : $this->getModel()->newInstance(); if ($model instanceof Applicationable) { ApplicationableHelper::addApplication($model); } $model->fill($values); if (isset($values['fields'])) { $model->setFields($values['fields']); } if (isset($values['variants'])) { $model->setVariants($values['variants']); } $model->save(); return $model; }
public function createOrUpdate($values, $id = null) { /** @var User $user */ $user = $id ? $this->read($id) : $this->getModel()->newInstance(); if ($user instanceof Applicationable) { ApplicationableHelper::addApplication($user); } if (array_key_exists('email', $values) and !env('ACTIVATE_ALL_USERS')) { $values['temporary_email'] = $values['email']; if ($id) { unset($values['email']); } $user->createVerifyEmailToken(); } $user->fill($values)->save(); \Event::fire($id ? new Update($user) : new Create($user)); return $user; }