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


PHP Model::getOriginal方法代码示例

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


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

示例1: updateCache

 /**
  * Update the cache for all operations.
  *
  * @param Model $model
  */
 public function updateCache(Model $model)
 {
     $this->model = $model;
     $this->applyToCountCache(function ($config) {
         $foreignKey = $this->key($this->model, $config['foreignKey']);
         if ($this->model->getOriginal($foreignKey) && $this->model->{$foreignKey} != $this->model->getOriginal($foreignKey)) {
             $this->update($config, '-', $this->model->getOriginal($foreignKey));
             $this->update($config, '+', $this->model->{$foreignKey});
         }
     });
 }
开发者ID:kasoprecede47,项目名称:eloquence,代码行数:16,代码来源:CountCacheManager.php

示例2: updated

 /**
  * On update, delete previous file if changed
  *
  * @param  Model $model eloquent
  * @return mixed false or void
  */
 public function updated(Model $model)
 {
     if (!($attachments = $model->attachments)) {
         return;
     }
     foreach ($attachments as $fieldname) {
         // Nothing to do if file did not change
         if ($model->getOriginal($fieldname) == $model->{$fieldname}) {
             return;
         }
         Croppa::delete('/uploads/' . $model->getTable() . '/' . $model->getOriginal($fieldname));
     }
 }
开发者ID:mrkodssldrf,项目名称:TypiCMS,代码行数:19,代码来源:FileObserver.php

示例3: updating

 /**
  * Observe model saving for User.
  *
  * @param  \Illuminate\Database\Eloquent\Model  $model
  *
  * @return void
  */
 public function updating(Model $model)
 {
     $changes = [];
     $watchlist = (array) Arr::get($this->config, 'watchlist', []);
     foreach ($watchlist as $attribute) {
         if ($model->isDirty($attribute)) {
             $changes[$attribute] = $model->getAttribute($attribute);
         }
     }
     $recipient = new GenericRecipient($model->getOriginal('email'), $model->getRecipientName());
     $this->factory->notify($recipient, $model, $changes, $this->config);
 }
开发者ID:laravie,项目名称:warden,代码行数:19,代码来源:UserObserver.php

示例4: updated

 /**
  * On update, delete previous file if changed
  * 
  * @param  Model $model eloquent
  * @return mixed false or void
  */
 public function updated(Model $model)
 {
     if (!($attachments = $model->attachments)) {
         return;
     }
     foreach ($attachments as $fieldname) {
         // Nothing to do if file did not change
         if (!$model->isDirty($fieldname)) {
             continue;
         }
         $file = '/uploads/' . $model->getTable() . '/' . $model->getOriginal($fieldname);
         $this->delete($file);
     }
 }
开发者ID:Ayoubblog,项目名称:TypiCMS,代码行数:20,代码来源:FileObserver.php

示例5: 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

示例6: updating

 public function updating(\Illuminate\Database\Eloquent\Model $model)
 {
     //	An node is being updated.
     //	Rebuild the tree if the parent was changed.
     //	Get column names.
     //	Missing required columns will throw an exception.
     $pkColumn = $model->getKeyName();
     $leftColumn = $model->getLeftColumn();
     $rightColumn = $model->getRightColumn();
     $parentColumn = $model->getParentColumn();
     $depthColumn = $model->getDepthColumn();
     $groupColumn = $model->getGroupColumn();
     $originalParentId = $model->getOriginal($parentColumn);
     if ($originalParentId !== $model->{$parentColumn}) {
         $model->syncOriginalAttribute($parentColumn);
         echo 'parent changed from "' . $originalParentId . '" to "' . $model->{$parentColumn} . '"';
         if (!is_null($originalParentId)) {
             //	Load original parent
             $originalParent = $model::findOrFail($originalParentId, array_filter([$pkColumn, $leftColumn, $rightColumn, $depthColumn, $groupColumn]));
         }
         if (!is_null($model->{$parentColumn})) {
             //	Load new parent
             $newParent = $model::findOrFail($model->{$parentColumn}, array_filter([$pkColumn, $leftColumn, $rightColumn, $depthColumn, $groupColumn]));
             if ($newParent->{$leftColumn} > $model->{$leftColumn} and $newParent->{$leftColumn} < $model->{$rightColumn}) {
                 //	This change would create a circular tree.
                 throw new \Exception('Changing this node\'s parent to ' . $model->{$parentColumn} . ' creates a circular reference');
             }
         }
         //$originalParent = $model->where
         //	@TODO:	Move this to the Trait. Override save().
         dd($modelId);
         /*
         SELECT id FROM node
         WHERE node.left BETWEEN 1 AND 10
         AND node.id = 8
         */
         //	Rebuild the entire tree.
         //	@TODO:	Be smarter about this method.
         dd($model);
         $rootNode = $model::where($parentColumn, '=', null)->first();
         $rootNode->buildTree();
     }
     return true;
 }
开发者ID:tvad911,项目名称:nestedset,代码行数:44,代码来源:NestedSetObserver.php

示例7: processRecursiveRollbackOperation

 /**
  * Processes a recursive rollback operation.
  *
  * @param mixed $movement
  *
  * @return array
  */
 protected function processRecursiveRollbackOperation(Model $movement)
 {
     /*
      * Retrieve movements that were created after
      * the specified movement, and order them descending
      */
     $movements = $this->movements()->where('created_at', '>=', $movement->getOriginal('created_at'))->orderBy('created_at', 'DESC')->get();
     $rollbacks = [];
     if ($movements->count() > 0) {
         foreach ($movements as $movement) {
             $rollbacks = $this->processRollbackOperation($movement);
         }
     }
     return $rollbacks;
 }
开发者ID:stevebauman,项目名称:inventory,代码行数:22,代码来源:InventoryStockTrait.php

示例8: noUpload

 /**
  * Handle the case where no file has been uploaded for a field, but the field may have been cleared.
  *
  * @param Model  $model
  * @param string $fieldName
  */
 private function noUpload(Model $model, $fieldName)
 {
     $prevFilePath = $model->getOriginal($fieldName);
     if (!exists($model->{$fieldName}) && exists($prevFilePath)) {
         $this->deleteFile($prevFilePath);
     }
 }
开发者ID:electro-modules,项目名称:matisse-components,代码行数:13,代码来源:ImageFieldHandler.php

示例9: getDefaultValueFor

 /**
  * @param $attribute
  * @return array|mixed
  */
 public function getDefaultValueFor($attribute)
 {
     return $this->model->getOriginal($attribute);
 }
开发者ID:deargonauten,项目名称:translaravel,代码行数:8,代码来源:ModelTranslator.php

示例10: getBefore

 /**
  * Get the model's "before" snapshot.
  *
  * @return array
  */
 protected function getBefore()
 {
     $lookupTable = ['created' => null, 'updated' => array_intersect_key($this->model->getOriginal(), $this->getAfter()), 'deleted' => $this->model->getAttributes(), 'soft-deleted' => ['deleted_at' => $this->model->{$this->model->getDeletedAtColumn()}], 'restored' => ['deleted_at' => $this->model->{$this->model->getDeletedAtColumn()}]];
     return collect($lookupTable)->get($this->getEvent());
 }
开发者ID:cklmercer,项目名称:laravel-model-time-machine,代码行数:10,代码来源:SnapShotFactory.php

示例11: restored

 public function restored(Eloquent $object)
 {
     $object->logs()->create(['type' => Model::RESTORE, 'data' => $object->getOriginal()]);
 }
开发者ID:dkulyk,项目名称:eloquent-extra,代码行数:4,代码来源:Listener.php

示例12: deleted

 public function deleted(Model $model)
 {
     $oldNode = $model->getOriginal('node');
     DB::table($model->getTable())->where(DB::raw("LOCATE('{$oldNode}', `node`)"), '>', 0)->delete();
 }
开发者ID:vergil-lai,项目名称:node-categoires,代码行数:5,代码来源:Observer.php

示例13: update

 /**
  * Update the cache for all operations.
  */
 public function update()
 {
     $this->apply(function ($config) {
         $foreignKey = $this->key($config['foreignKey']);
         if ($this->model->getOriginal($foreignKey) && $this->model->{$foreignKey} != $this->model->getOriginal($foreignKey)) {
             $this->updateCacheRecord($config, '-', 1, $this->model->getOriginal($foreignKey));
             $this->updateCacheRecord($config, '+', 1, $this->model->{$foreignKey});
         }
     });
 }
开发者ID:bronxct1,项目名称:eloquence,代码行数:13,代码来源:CountCache.php


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