當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。