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