/** * 创建 * * @param array $input * @return News * @throws GeneralException */ public function create(array $input) { if ($id = parent::create($input)) { return $id; } throw new GeneralException('There was a problem creating this news. Please try again.'); }
public function create(array $attributes) { try { return parent::create($attributes); } catch (QueryException $e) { throw new RepositoryException('Cannot save the entity!', null, $e); } }
/** * @param array $attributes * @return mixed */ public function create(array $attributes) { $attributes['password'] = bcrypt($attributes['password']); $attributes = collect($attributes); $user = parent::create($attributes->only('email', 'name', 'password')->all()); $this->updateRoles($user, $attributes); event(new UserWasCreated($user, $attributes)); return $this->parserResult($user); }
/** * Save a new entity in repository * * @throws ValidatorException * @param array $attributes * @return mixed */ public function createByAdmin(array $attributes) { parent::skipPresenter(); $attributes['password_last_set'] = new Carbon(); if (array_has($attributes, 'must_change_password')) { $attributes['password_last_set'] = null; } $user = parent::create($attributes); $this->updateProfile($attributes, $user['id']); return $user; }
/** * Create model * * @param array $attributes * * @return Model */ public function create(array $attributes) { $defaults = ['roles' => []]; $attributes = array_merge($defaults, $attributes); $model = parent::create($attributes); if (!in_array('Esensi\\Model\\Contracts\\HashingModelInterface', class_implements($model))) { throw new Exception("User model must implement Esensi\\Model\\Contracts\\HashingModelInterface.\n Revert to 0.3.* or see upgrade guide for details."); } $model->roles()->sync($attributes['roles']); return $this->parserResult($model); }
/** * Save a new entity in repository * * @throws ValidatorException * @param array $attributes * @return mixed */ public function createByAdmin(array $attributes, $roles = null) { parent::skipPresenter(); $attributes['password_last_set'] = new Carbon(); if (array_has($attributes, 'must_change_password')) { $attributes['password_last_set'] = null; } $attributes['password'] = bcrypt($attributes['password']); $user = parent::create($attributes); $user->roles()->sync($roles); return $user; }
/** * @param array $data * @return array|mixed */ public function create(array $data) { return $this->repository->create($data); }
/** * Save a new user * * @param array $attributes * @throws ValidatorException * @return mixed */ public function create(array $attributes) { $attributes = $this->hashPassword($attributes); return parent::create($attributes); }