/** * Save a new entity in repository * * @param array $attributes * @return mixed|Model */ public function create(array $attributes) { return $this->wrap(function ($attributes) { $model = $this->model->newInstance($attributes); /** * @var Model $model */ $model->save(); return $model; }, new Action(__METHOD__, func_get_args(), Action::CREATE)); }
/** * Return a new instance of the current model. * * @param array $attributes * * @return static */ public function newInstance(array $attributes = []) { return $this->model->newInstance($attributes); }
public function create($object) { $newVersion = $this->version->newInstance(['hash' => sha1(time() . serialize($object)), 'object' => $object]); $object->versions()->save($newVersion); return $newVersion; }