本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::create方法的具体用法?PHP Model::create怎么用?PHP Model::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Model
的用法示例。
在下文中一共展示了Model::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
public function store(CreateRoleRequest $request)
{
$data = $request->only(['name', 'description']);
$this->roleModel->create($data);
$this->setStatusMessage(trans('aliukevicius/laravelRbac::lang.role.messageCreated', ['name' => $data['name']]));
return \Redirect::to($this->getRoleUrl('index'));
}
示例2: create
/**
* {@inheritdoc}
*/
public function create(array $data)
{
$instance = $this->model->create($data);
if (!$instance->getKey()) {
throw new EntityCreateException('Failed to create entity');
}
return $instance;
}
示例3: create
/**
* Create a new model
*
* @param array Data to create a new object
* @return boolean
*/
public function create(array $data)
{
$model = $this->model->create($data);
if (!$model) {
return false;
}
return $model;
}
示例4: insert
/**
* Performs INSERT.
*
* @param $row
*/
protected function insert($row)
{
if ($this->dryRun) {
return;
}
$record = $this->model->create($row);
}
示例5: create
public static function create(array $attributes = [])
{
if (array_key_exists('attachment', $attributes)) {
$attributes['attachment'] = static::processAttachment($attributes['attachment']);
}
return parent::create($attributes);
}
示例6: store
/**
* Create a new model instance and store it in the database
*
* @param array $data
* @return static
*/
public function store(array $data)
{
// Remove non-fillable items from our data array
foreach ($data as $key => $value) {
if (!in_array($key, $this->model->getFillable())) {
unset($data[$key]);
}
}
// Do we need to create a reference id?
$referenceColumn = $this->referenceIdColumnName();
if ($this->model->isFillable($referenceColumn) && !isset($data[$referenceColumn])) {
$data[$referenceColumn] = $this->generateReferenceId();
}
// Return the new model object
return $this->model->create($data);
}
示例7: create
/**
* Create the model in the database.
*
* @param array $attributes
* @return category
*/
public static function create(array $attributes = [])
{
if (empty($attributes['alias'])) {
$attributes['alias'] = Str::slug($attributes['name']) . '-' . Uuid::generate(4);
}
return parent::create($attributes)->fresh();
}
示例8: create
/**
* Create a new model.
*
* @param array $input
* @throws Exception
* @return mixed
*/
public static function create(array $input)
{
static::beforeCreate($input);
$return = parent::create($input);
static::afterCreate($input, $return);
return $return;
}
示例9: create
/**
* Save a new model and return the instance.
*
* @param array $attributes
* @return static
*/
public static function create(array $attributes = [])
{
if (Guardian::hasClients()) {
$attributes[Guardian::getClientColumn()] = Guardian::getClientId();
}
return parent::create($attributes);
}
示例10: create
public static function create(array $attributes = [])
{
if (!array_key_exists('start_date', $attributes)) {
throw new \RTMatt\MonthlyService\Exceptions\ServiceMonthNoDateException();
}
return parent::create($attributes);
}
示例11: create
/**
* @param array $data
*
* @return mixed
*/
public function create(array $data)
{
$this->validate($data, ValidatorInterface::RULE_CREATE);
$results = $this->model->create($data);
$this->resetModel();
return $this->parseResult($results);
}
示例12: store
/**
* Create a new model instance and store it in the database
*
* @param array $data
* @return static
*/
public function store(array $data)
{
// Do we need to create a reference id?
if ($this->model->isFillable('ref') && !isset($data['ref'])) {
$data['ref'] = $this->generateReferenceId();
}
// Create the new model object
$model = $this->model->create($data);
// Do we need to set a hash?
if ($this->model->isFillable('hash')) {
$model->hash = \Hashids::encode($model->id);
$model->save();
}
// Return the new model object
return $model;
}
示例13: create
public static function create(array $attributes = [])
{
if (config('global.managers.current.id')) {
$data = array_merge($attributes, ['manager_id' => config('global.managers.current.id'), 'ip' => config('global.ip.current'), 'origin' => config('global.origin.current')]);
parent::create($data);
}
}
示例14: create
/**
* Create the model in the database.
*
* @param array $attributes
* @return category
*/
public static function create(array $attributes = [])
{
if (empty($attributes['alias'])) {
$attributes['alias'] = Str::slug($attributes['title']);
}
$attributes['user_id'] = Auth::user()->id;
return parent::create($attributes)->fresh();
}
示例15: create
/**
* Override of the create function, to incorporate a salt for password generation
*
* @param array attributes[];
*/
public static function create(array $attributes = [])
{
if (self::isUnguarded()) {
$attributes['password'] = password_hash($attributes['password'], PASSWORD_BCRYPT);
$model = parent::create($attributes);
return $model;
}
}