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


PHP Model::getAttribute方法代码示例

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


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

示例1: resolveModelToArray

 /**
  * @param Model $oModel
  * @return array
  */
 protected function resolveModelToArray(Model $oModel)
 {
     /** @var Key $oKey */
     $oKey = $oModel->getAttribute("key");
     /** @var Locale $oLocale */
     $oLocale = $oModel->getAttribute("locale");
     $aReturn = [$oModel->getKeyName() => $oModel->getKey(), "key" => $oKey ? $oKey->getAttribute(Key::COLUMN_NAME) : null, "locale" => $oLocale ? $oLocale->getAttribute(Locale::COLUMN_CODE) : null, Message::COLUMN_TEXT => $oModel->getAttribute(Message::COLUMN_TEXT)];
     return $aReturn;
 }
开发者ID:samcrosoft,项目名称:MicroTranslate,代码行数:13,代码来源:MessageTransformer.php

示例2: setDisplay

 /**
  * @param Model $result
  * @return string
  */
 protected function setDisplay($result)
 {
     if (is_array($this->config['display'])) {
         $displayString = '';
         foreach ($this->config['display'] as $key => $display) {
             if ($key !== 0) {
                 $displayString .= ' | ';
             }
             $displayString .= $result->getAttribute($display);
         }
         return $displayString;
     }
     return $result->getAttribute($this->config['display']);
 }
开发者ID:ablunier,项目名称:crud,代码行数:18,代码来源:Select.php

示例3: getAttribute

 /**
  * Get an attribute from the model.
  *
  * @param  string  $key
  * @return mixed
  */
 public function getAttribute($key)
 {
     if ($key == 'id') {
         $key = '@rid';
     }
     return parent::getAttribute($key);
 }
开发者ID:pin-cnx,项目名称:orientdb-laravel-5,代码行数:13,代码来源:Model.php

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

示例5: getModelTitle

 /**
  * @param Model $model
  *
  * @return mixed
  */
 public function getModelTitle(Model $model)
 {
     if (is_string($this->title)) {
         return $model->getAttribute($this->title);
     }
     return call_user_func($this->title, $model);
 }
开发者ID:lazychaser,项目名称:shopping,代码行数:12,代码来源:TitlesFromModel.php

示例6: getAttribute

 public function getAttribute($key)
 {
     if ($this->hasAttribute($key)) {
         return parent::getAttribute($key);
     }
     return in_array($key, ['softDelete']) ? null : new FieldValue('{}');
 }
开发者ID:alpas29,项目名称:cms,代码行数:7,代码来源:DvsPage.php

示例7: valueFromModel

 /**
  * Get the value from the model.
  *
  * @param  string $name
  * @return mixed|null
  */
 protected function valueFromModel($name)
 {
     if (!$this->model) {
         return null;
     }
     return $this->model->getAttribute($name);
 }
开发者ID:sahibalejandro,项目名称:laravel-form-helpers,代码行数:13,代码来源:Form.php

示例8: isFacebookUserExisted

 /**
  * Kiểm tra xem facebook user đã có trong sentinel-user chưa
  * Nếu có trả về user model
  * Chưa có trả về false
  *
  * @param \Illuminate\Database\Eloquent\Model $facebookUser
  *
  * @return bool | Model
  */
 public function isFacebookUserExisted(Model $facebookUser)
 {
     if (!!$facebookUser->getAttribute('user_id')) {
         return $facebookUser->user;
     } else {
         return false;
     }
 }
开发者ID:vjcspy,项目名称:izcustomer,代码行数:17,代码来源:FacebookUser.php

示例9: associate

 /**
  * Associate the model instance to the given parent.
  *
  * @param  \Illuminate\Database\Eloquent\Model  $model
  * @return \Sgpatil\Orientdb\Eloquent\Edges\Relation
  */
 public function associate($model, $attributes = array())
 {
     $otherKey = $model instanceof Model ? $model->getAttribute($this->otherKey) : $model;
     $this->parent->setAttribute($this->foreignKey, $otherKey);
     if ($model instanceof Model) {
         $this->parent->setRelation($this->relation, $model);
     }
     return $this->parent;
 }
开发者ID:pin-cnx,项目名称:orientdb-laravel-5,代码行数:15,代码来源:OneRelation.php

示例10: saving

 /**
  * Add the slug when not explicitly stated.
  *
  * @param  Model  $model
  * @return void
  */
 public function saving(Model $model)
 {
     $hasManuallyAssignedSlug = $model->slug && $model->isDirty('slug');
     if (!$model->isDirty('name') || $hasManuallyAssignedSlug) {
         return;
     }
     $slug = str_slug($model->getAttribute($this->fieldToSlug));
     $model->setAttribute($this->slugAttribute, $slug);
 }
开发者ID:salpakan,项目名称:salpakan,代码行数:15,代码来源:AddSlugAttribute.php

示例11: getModelValue

 /**
  * @return mixed
  */
 protected function getModelValue()
 {
     $value = $this->model->getAttribute($this->getModelKey());
     if ($value instanceof Model) {
         $value = $value->getAttribute($value->getKeyName());
     } elseif ($value instanceof Collection) {
         $value = $value->pluck('id')->all();
     }
     return $value;
 }
开发者ID:KodiComponents,项目名称:module-core,代码行数:13,代码来源:ModelField.php

示例12: getAttribute

 /**
  * Get an attribute from the model with custom accessor.
  *
  * @param  string $key
  * @return mixed
  */
 public function getAttribute($key)
 {
     if (isset($this->mutations[$key])) {
         return $this->mutations[$key];
     }
     if (array_key_exists($key, $mutatables = static::getMutatables())) {
         return $this->mutateExtensionAttribute($key, $mutatables[$key]);
     }
     return parent::getAttribute($key);
 }
开发者ID:NuclearCMS,项目名称:Hierarchy,代码行数:16,代码来源:NodeSourceExtension.php

示例13: performInsert

 /**
  * Save a new model and attach it to the parent model.
  *
  * @param  \Illuminate\Database\Eloquent\Model  $model
  * @return \Illuminate\Database\Eloquent\Model
  */
 protected function performInsert(Model $model)
 {
     // Create a new key if needed.
     if (!$model->getAttribute('_id')) {
         $model->setAttribute('_id', new MongoId());
     }
     $result = $this->query->update(array($this->localKey => $model->getAttributes()));
     if ($result) {
         $this->associate($model);
     }
     return $result ? $model : false;
 }
开发者ID:reverserob,项目名称:laravel-mongodb,代码行数:18,代码来源:EmbedsOne.php

示例14: format_date_form_field

/**
 * Format a Carbon date if available to a simplified format
 * for form input element. Uses old data if available.
 *
 * @param  \Illuminate\Database\Eloquent\Model  $model
 * @param  string  $field
 * @param  string  $default
 * @return string
 */
function format_date_form_field($model, $field, $default = 'MM/DD/YYYY')
{
    $oldDate = old($field);
    if ($oldDate) {
        return $oldDate;
    }
    $attribute = $model->getAttribute($field);
    if ($attribute && $attribute instanceof Carbon) {
        return $attribute->format('Y-m-d');
    }
    return $default;
}
开发者ID:DoSomething,项目名称:gladiator,代码行数:21,代码来源:helpers.php

示例15: getAttribute

 /**
  * Get an attribute from the model.
  *
  * @param  string $key
  * @throws \Exception
  * @return mixed
  */
 public function getAttribute($key)
 {
     // If the attribute is not already available to the
     // model, let's look for any configured relationships
     // that match the $key and return a Collection|static
     if (!($attribute = parent::getAttribute($key))) {
         if ($relationship = $this->resolveRelationship($key)) {
             $attribute = $relationship->getResults();
             $this->relations[$key] = $relationship;
         }
     }
     return $attribute;
 }
开发者ID:master0mind,项目名称:Lavender,代码行数:20,代码来源:Entity.php


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