当前位置: 首页>>代码示例>>PHP>>正文


PHP Model::create方法代码示例

本文整理汇总了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'));
 }
开发者ID:aliukevicius,项目名称:laravel-rbac,代码行数:7,代码来源:RoleController.php

示例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;
 }
开发者ID:3ev,项目名称:repoman,代码行数:11,代码来源:Repository.php

示例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;
 }
开发者ID:avin,项目名称:library,代码行数:14,代码来源:EloquentBaseRepository.php

示例4: insert

 /**
  * Performs INSERT.
  *
  * @param $row
  */
 protected function insert($row)
 {
     if ($this->dryRun) {
         return;
     }
     $record = $this->model->create($row);
 }
开发者ID:pmatseykanets,项目名称:artisan-io,代码行数:12,代码来源:ModelImport.php

示例5: create

 public static function create(array $attributes = [])
 {
     if (array_key_exists('attachment', $attributes)) {
         $attributes['attachment'] = static::processAttachment($attributes['attachment']);
     }
     return parent::create($attributes);
 }
开发者ID:rtmatt,项目名称:rtclientmanager,代码行数:7,代码来源:PriorityAlert.php

示例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);
 }
开发者ID:srlabs,项目名称:groundwork,代码行数:22,代码来源:BaseRepository.php

示例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();
 }
开发者ID:toancong,项目名称:laravel-articles,代码行数:13,代码来源:Category.php

示例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;
 }
开发者ID:christiannwamba,项目名称:laravel-site,代码行数:14,代码来源:BaseModel.php

示例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);
 }
开发者ID:emilmoe,项目名称:guardian,代码行数:13,代码来源:Role.php

示例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);
 }
开发者ID:rtmatt,项目名称:rtclientmanager,代码行数:7,代码来源:ServiceMonth.php

示例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);
 }
开发者ID:killtw,项目名称:repository,代码行数:12,代码来源:BaseRepository.php

示例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;
 }
开发者ID:leek,项目名称:laravel-testing-utilities,代码行数:22,代码来源:BaseRepository.php

示例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);
     }
 }
开发者ID:PingadoWeb,项目名称:deliveryApi,代码行数:7,代码来源:Logs.php

示例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();
 }
开发者ID:toancong,项目名称:laravel-articles,代码行数:14,代码来源:Article.php

示例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;
     }
 }
开发者ID:MixedBerries,项目名称:blueberry-core,代码行数:13,代码来源:User.php


注:本文中的Illuminate\Database\Eloquent\Model::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。