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


PHP Model::getConnectionName方法代码示例

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


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

示例1: getModels

 /**
  * Get the hydrated models without eager loading.
  *
  * @param  array  $columns
  * @return \Illuminate\Database\Eloquent\Model[]
  */
 public function getModels($columns = ['*'])
 {
     $results = $this->query->get($columns);
     $connection = $this->model->getConnectionName();
     return $this->model->hydrate($results, $connection)->all();
 }
开发者ID:drickferreira,项目名称:rastreador,代码行数:12,代码来源:Builder.php

示例2: getConnectionName

 /**
  * Get the current connection name for the model.
  *
  * @return string
  */
 public function getConnectionName()
 {
     $tenant = tenant();
     if (is_null($tenant)) {
         return parent::getConnectionName();
     }
     return array_get($tenant, 'id');
 }
开发者ID:kwalit,项目名称:multi-tenant,代码行数:13,代码来源:TenantModel.php

示例3: getConnectionName

 /**
  * @return string
  */
 public function getConnectionName()
 {
     // overrules connection name in case of using multi tenancy
     if (env('HYN_MULTI_TENANCY_HOSTNAME') && is_null($this->connection)) {
         return 'tenant';
     }
     // fallback to parent method
     return parent::getConnectionName();
 }
开发者ID:hyn,项目名称:framework,代码行数:12,代码来源:AbstractModel.php

示例4: __construct

 /**
  * Create a new pivot model instance.
  *
  * @param  \Illuminate\Database\Eloquent\Model  $parent
  * @param  array   $attributes
  * @param  string  $table
  * @param  bool    $exists
  * @return void
  */
 public function __construct(Model $parent, $attributes, $table, $exists = false)
 {
     parent::__construct();
     // The pivot model is a "dynamic" model since we will set the tables dynamically
     // for the instance. This allows it work for any intermediate tables for the
     // many to many relationship that are defined by this developer's classes.
     $this->setRawAttributes($attributes, true);
     $this->setTable($table);
     $this->setConnection($parent->getConnectionName());
     // We store off the parent instance so we will access the timestamp column names
     // for the model, since the pivot model timestamps aren't easily configurable
     // from the developer's point of view. We can use the parents to get these.
     $this->parent = $parent;
     $this->exists = $exists;
     $this->timestamps = $this->hasTimestampAttributes();
 }
开发者ID:GeorgeBroadley,项目名称:caffeine-vendor,代码行数:25,代码来源:Pivot.php

示例5: getModels

 /**
  * Get the hydrated models without eager loading.
  *
  * @param  array  $columns
  * @return array|static[]
  */
 public function getModels($columns = array('*'))
 {
     // First, we will simply get the raw results from the query builders which we
     // can use to populate an array with Eloquent models. We will pass columns
     // that should be selected as well, which are typically just everything.
     $results = $this->query->get($columns);
     $connection = $this->model->getConnectionName();
     $models = array();
     // Once we have the results, we can spin through them and instantiate a fresh
     // model instance for each records we retrieved from the database. We will
     // also set the proper connection name for the model after we create it.
     foreach ($results as $result) {
         $models[] = $model = $this->model->newFromBuilder($result);
         $model->setConnection($connection);
     }
     return $models;
 }
开发者ID:aysenli,项目名称:laravel-admin-1,代码行数:23,代码来源:Builder.php

示例6: is

 /**
  * Determine if two models have the same ID and belong to the same table.
  *
  * @param  \Illuminate\Database\Eloquent\Model  $model
  * @return bool
  */
 public function is(Model $model)
 {
     return $this->getKey() === $model->getKey() && $this->getTable() === $model->getTable() && $this->getConnectionName() === $model->getConnectionName();
 }
开发者ID:scrubmx,项目名称:framework,代码行数:10,代码来源:Model.php

示例7: generateCacheKey

 /**
  * Generate a cache key
  *
  * @return string
  */
 public function generateCacheKey()
 {
     return md5($this->model->getConnectionName() . $this->builder->toSql() . serialize($this->builder->getBindings()));
 }
开发者ID:renatogcarvalho,项目名称:feeder,代码行数:9,代码来源:Repository.php

示例8: hydrate

 /**
  * Hydrate related models.
  *
  * @param  Model    $related
  * @param  Relation $relation
  * @param  array    $results
  * @return array
  */
 protected function hydrate(Model $related, Relation $relation, array $results)
 {
     $models = $related->hydrate($results, $related->getConnectionName())->all();
     if (count($models) > 0 && method_exists($relation, 'hydratePivotRelation')) {
         $r = new ReflectionMethod(get_class($relation), 'hydratePivotRelation');
         $r->setAccessible(true);
         $r->invoke($relation, $models);
     }
     return $models;
 }
开发者ID:nuwave,项目名称:lighthouse,代码行数:18,代码来源:QueryBuilder.php

示例9: addValue

 /**
  * Add new Value to entity.
  *
  * @param Property $property
  * @param mixed    $value
  *
  * @return Value
  */
 public function addValue(Property $property, $value)
 {
     $instance = self::getType($property->type);
     if ($instance !== null) {
         $v = $instance->newInstance([], false);
     } else {
         $v = new Value();
     }
     $v->setConnection($this->entity->getConnectionName());
     $v->setRelation('property', $property);
     $v->forceFill(['property_id' => $property->getKey(), 'value' => $value]);
     if ($property->multiple) {
         $this->getPropertyValue($property->name)->push($v);
     } else {
         $this->getPropertyValues($property->name)->put($property->name, $v);
     }
     return $v;
 }
开发者ID:dkulyk,项目名称:eloquent-extra,代码行数:26,代码来源:Factory.php


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