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


PHP Model::fill方法代码示例

本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::fill方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::fill方法的具体用法?PHP Model::fill怎么用?PHP Model::fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Database\Eloquent\Model的用法示例。


在下文中一共展示了Model::fill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: insert

 /**
  * @param array $data
  * @return bool
  */
 public function insert(array $data = [])
 {
     $this->source->fill($data);
     if ($this->source->save()) {
         return $this->source->getKey();
     }
     return false;
 }
开发者ID:cocona,项目名称:core,代码行数:12,代码来源:EloquentResource.php

示例2: dataForCompany

 public function dataForCompany(array $data)
 {
     $tes = \DB::table($this->throughTableName)->whereCompanyId($this->companyId)->whereId($this->throughId)->get();
     if (empty($tes)) {
         throw new \Exception('thorugh data not found');
     }
     $foreignId = str_singular($this->throughTableName) . '_id';
     $data[$foreignId] = $this->throughId;
     return $this->model->fill($data);
 }
开发者ID:rekale,项目名称:sikasir,代码行数:10,代码来源:EloquentThroughCompany.php

示例3: fill

 /**
  * Override to ensure uuid is set, so everything can be referenced from that
  * parameter, rather than from an integer parameter.
  *
  * @param array $attributes
  *
  * @return $this
  */
 public function fill(array $attributes)
 {
     if (empty($attributes['uuid'])) {
         $attributes['uuid'] = Uuid::uuid4()->toString();
     }
     return parent::fill($attributes);
 }
开发者ID:rupertjeff,项目名称:ascension-card-db,代码行数:15,代码来源:Model.php

示例4: save

 /**
  *
  */
 protected function save()
 {
     $data = $this->request->all();
     $this->modelItem->getForm()->updateRequestData($data);
     $rules = $this->modelItem->getForm()->getValidationRules();
     $this->instance->validate($data, $rules);
     $this->instance->fill($data);
     $this->instance->save();
 }
开发者ID:GlobalsDD,项目名称:admin,代码行数:12,代码来源:ModelRepository.php

示例5: toModel

 /**
  * {@inheritDoc}
  */
 public function toModel(Result $result, Model $model)
 {
     $exclude = ['location', 'full_address'];
     $filtered = array_diff_key($result->getSource(), array_flip($exclude));
     $model->exists = true;
     $model->id = $result->getId();
     $model->fill($filtered);
     return $model;
 }
开发者ID:phpfour,项目名称:ah,代码行数:12,代码来源:LocationTransformer.php

示例6: fill

 public function fill(array $attributes)
 {
     parent::fill($attributes);
     if (array_key_exists('slug', $attributes) === false && array_key_exists('title', $attributes)) {
         // create slug
         $slugify = new Slugify();
         $this->slug = $slugify->slugify($attributes['title']);
     }
     return $this;
 }
开发者ID:alcodo,项目名称:alpaca,代码行数:10,代码来源:Topic.php

示例7: _update

 /**
  * Update an exsiting resource.
  *
  * @param  Request
  * @param  int $id
  * @return Response
  */
 protected function _update(Request $request, $id)
 {
     // Get the resource if it has not been provided by the child class
     if (!$this->resource->getKey()) {
         $this->resource = $this->resource->findOrFail($id);
     }
     // Transfer input to the resource
     $this->resource = $this->resource->fill($request->input());
     // Save to the storage
     return $this->save(__FUNCTION__);
 }
开发者ID:LeandrosilvaDG,项目名称:Wiki,代码行数:18,代码来源:ResourceController.php

示例8: saveModelData

 /**
  * Save file attributes required for interpolation to model
  *
  * @param string|Illuminate\Database\Eloquent\Model $model
  * @param Ideil\LaravelFileOre\Interpolator\InterpolatorResult $input
  *
  * @return Illuminate\Database\Eloquent\Model
  */
 protected function saveModelData(Model $model, Interpolator\InterpolatorResult $input)
 {
     // prepare data to fill model
     $model_map = $model->getFileAssignMap();
     $model_fields = [];
     foreach ($input->getData() as $field => $value) {
         $model_fields[isset($model_map[$field]) ? $model_map[$field] : $field] = $value;
     }
     // not save, just fill data
     $model->fill($model_fields);
     return $model;
 }
开发者ID:ideil,项目名称:laravel-fileore,代码行数:20,代码来源:FileOre.php

示例9: fillModel

 /**
  * fill model datas to database
  *
  * @param array $datas
  * @return boolean
  */
 protected function fillModel($datas)
 {
     $grouped = collect($datas)->groupBy('relation_type');
     foreach ($grouped as $key => $groups) {
         // no relation
         if ($key === 'not') {
             foreach ($groups as $group) {
                 $this->model->fill($group['datas'])->save();
             }
             continue;
         }
         // hasOne relation
         if ($key === 'hasOne') {
             foreach ($groups as $group) {
                 $relation = $group['relation'];
                 if (is_null($this->model->{$relation})) {
                     $this->model->{$relation}()->save(new $group['relation_model']($group['datas']));
                     continue;
                 }
                 $this->model->{$relation}->fill($group['datas'])->save();
             }
             continue;
         }
         // hasMany relation
         if ($key === 'hasMany') {
             foreach ($groups as $group) {
                 $relation = $group['relation'];
                 $relation_models = [];
                 foreach ($group['datas'] as $data) {
                     $relation_models[] = new $group['relation_model']($data);
                 }
                 if (isset($group['is_reset']) && $group['is_reset']) {
                     $this->model->{$relation}()->delete();
                 }
                 // bu if image banner için eklenmiştir
                 if (isset($group['changeToHasOne']) && $group['changeToHasOne']) {
                     if (is_null($this->model->{$group['changeToHasOne']})) {
                         $this->model->{$group['changeToHasOne']}()->save(new $group['relation_model']($group['datas'][0]));
                         continue;
                     }
                     $this->model->{$group['changeToHasOne']}->fill($group['datas'][0])->save();
                     continue;
                 }
                 $this->model->{$relation}()->saveMany($relation_models);
             }
             continue;
         }
         return false;
     }
     return true;
 }
开发者ID:erenmustafaozdal,项目名称:laravel-modules-base,代码行数:57,代码来源:OperationTrait.php

示例10: withNewItem

 /**
  * @param Model $model
  * @param array $rules
  * @param TransformerAbstract $transformer
  * @return ResponseFactory
  */
 public function withNewItem($model, $rules, $transformer)
 {
     $data = Request::all();
     if (isset($data['data'])) {
         if (is_array($data['data'])) {
             $data = $data['data'];
         }
     }
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         return $this->errorWrongArgsValidator($validator);
     }
     $model->fill($data);
     $model->save();
     return $this->setStatusCode(201)->withItem($model, $transformer);
 }
开发者ID:adrian-fjellberg,项目名称:SimpleApi,代码行数:22,代码来源:ApiResponse.php

示例11: save

 /**
  *
  */
 protected function save()
 {
     $data = $this->request->all();
     $this->modelItem->getForm()->updateRequestData($data);
     $rules = $this->modelItem->getForm()->getValidationRules();
     $this->instance->validate($data, $rules);
     $this->instance->fill($data);
     if (method_exists($this->instance, 'getRepository')) {
         if (method_exists($this->instance->getRepository(), 'saveFromArray')) {
             $this->instance->getRepository()->saveFromArray($data);
         } else {
             $this->instance->save();
         }
     } else {
         $this->instance->save();
     }
 }
开发者ID:procoders,项目名称:admin,代码行数:20,代码来源:ModelRepository.php

示例12: saving

 /**
  * On save, upload files.
  *
  * @param Model $model eloquent
  *
  * @return mixed false or void
  */
 public function saving(Model $model)
 {
     if (!($attachments = $model->attachments)) {
         return;
     }
     foreach ($attachments as $fieldname) {
         if (Request::hasFile($fieldname)) {
             // delete prev image
             $file = FileUpload::handle(Request::file($fieldname), 'uploads/' . $model->getTable());
             $model->{$fieldname} = $file['filename'];
             if ($model->getTable() == 'files') {
                 $model->fill($file);
             }
         } else {
             if ($model->{$fieldname} == 'delete') {
                 $model->{$fieldname} = null;
             } else {
                 $model->{$fieldname} = $model->getOriginal($fieldname);
             }
         }
     }
 }
开发者ID:eahrold,项目名称:Core,代码行数:29,代码来源:FileObserver.php

示例13: fillAndSave

 /**
  * Fills out an instance of the model
  * and saves it, pretty much like mass assignment.
  *
  * @param array $attributes
  *
  * @return \Illuminate\Database\Eloquent\Model
  */
 public function fillAndSave($attributes)
 {
     $this->model->fill($attributes);
     $this->model->save();
     return $this->model;
 }
开发者ID:vinelab,项目名称:lucid,代码行数:14,代码来源:Repository.php

示例14: secureFill

 public function secureFill(array $input)
 {
     $this->getFillableAttribute();
     return parent::fill($input);
 }
开发者ID:dwoodard,项目名称:IserveU,代码行数:5,代码来源:ApiModel.php

示例15: fill

 /**
  * @param array $attributes
  * @return $this
  */
 public function fill(array $attributes)
 {
     $language = array_get($attributes, 'language_id', $this->language_id);
     foreach ($attributes as $key => $value) {
         if ($this->isTranslatable($key)) {
             $this->translate($language)->setAttribute($key, $value);
             unset($attributes[$key]);
         }
     }
     return parent::fill($attributes);
 }
开发者ID:administrcms,项目名称:localization,代码行数:15,代码来源:Translatable.php


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