本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::getQualifiedKeyName方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::getQualifiedKeyName方法的具体用法?PHP Model::getQualifiedKeyName怎么用?PHP Model::getQualifiedKeyName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Model
的用法示例。
在下文中一共展示了Model::getQualifiedKeyName方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findMany
/**
* Find a model by its primary key.
*
* @param array $id
* @param array $columns
* @return \Illuminate\Database\Eloquent\Model|Collection|static
*/
public function findMany($id, $columns = array('*'))
{
if (empty($id)) {
return $this->model->newCollection();
}
$this->query->whereIn($this->model->getQualifiedKeyName(), $id);
return $this->get($columns);
}
示例2: checkQueryGroupBy
protected function checkQueryGroupBy()
{
$groups = $this->query->getQuery()->groups;
$keyGroup = $this->model->getQualifiedKeyName();
if (empty($groups) || !in_array($keyGroup, $groups)) {
$this->query->groupBy($keyGroup);
}
}
示例3: whereKey
/**
* Add a where clause on the primary key to the query.
*
* @param mixed $id
* @return $this
*/
public function whereKey($id)
{
if (is_array($id)) {
$this->query->whereIn($this->model->getQualifiedKeyName(), $id);
return $this;
}
return $this->where($this->model->getQualifiedKeyName(), '=', $id);
}
示例4: apply
/**
* Apply the scope to a given Eloquent query builder.
*
* @param \Illuminate\Database\Eloquent\Builder $builder
* @param \Illuminate\Database\Eloquent\Model $model
* @return void
*/
public function apply(Builder $builder, Model $model)
{
$builder->join($model->getVersionTable(), function ($join) use($model) {
$join->on($model->getQualifiedKeyName(), '=', $model->getQualifiedVersionKeyName());
$join->on($model->getQualifiedVersionColumn(), '=', $model->getQualifiedLatestVersionColumn());
});
$this->extend($builder);
}
示例5: each
/**
* Execute a callback over each item while chunking.
*
* @param callable $callback
* @param int $count
* @return bool
*/
public function each(callable $callback, $count = 1000)
{
if (is_null($this->query->orders) && is_null($this->query->unionOrders)) {
$this->orderBy($this->model->getQualifiedKeyName(), 'asc');
}
return $this->chunk($count, function ($results) use($callback) {
foreach ($results as $key => $value) {
if ($callback($value, $key) === false) {
return false;
}
}
});
}
示例6: generateJoinConstraints
/**
* @param JoinClause $query
* @param array $constraints
*
* @throws \InvalidArgumentException
*/
private function generateJoinConstraints($query, $constraints)
{
foreach ($constraints as $constraint) {
if (empty($constraint)) {
continue;
} elseif (is_array($constraint)) {
$constraint[2] = array_key_exists(2, $constraint) ? $constraint[2] : '=';
$this->transformCustomConstraint($query, $constraint[0], $constraint[1], $constraint[2]);
} elseif ($constraint instanceof Model) {
$query->where($constraint->getQualifiedKeyName(), '=', $constraint->getKey());
} elseif ($constraint instanceof Collection) {
$query->whereIn($constraint->first()->getQualifiedKeyName(), $constraint->modelKeys());
} elseif ($constraint instanceof \Closure) {
call_user_func($constraint, $query);
} elseif (is_int((int) $constraint)) {
$query->where($this->related->getQualifiedKeyName(), '=', $constraint);
} else {
throw new \InvalidArgumentException('Join constraint is not an object.', 500);
}
}
}
示例7: getHasCompareKey
/**
* Get the key for comparing against the parent key in "has" query.
*
* @return string
*/
public function getHasCompareKey()
{
return $this->farParent->getQualifiedKeyName();
}
示例8: getQualifiedParentKeyName
/**
* Get the fully qualified parent key name.
*
* @return string
*/
public function getQualifiedParentKeyName()
{
return $this->parent->getQualifiedKeyName();
}
示例9: resolveQualifiedKeyName
/**
* Get the key name to use when querying for records.
*
* If no key name has been specified for the model, `Model::getQualifiedKeyName()` will be used as the
* default.
*
* @param Model $model
* @param $resourceType
* @return string
*/
protected function resolveQualifiedKeyName(Model $model, $resourceType)
{
return isset($this->keyNames[$resourceType]) ? sprintf('%s.%s', $model->getTable(), $this->keyNames[$resourceType]) : $model->getQualifiedKeyName();
}
示例10: joinIntermediate
/**
* Join pivot or 'through' table.
*
* @param \Illuminate\Database\Eloquent\Model $parent
* @param \Illuminate\Database\Eloquent\Relations\Relation $relation
* @param string $type
* @return void
*/
protected function joinIntermediate(Model $parent, Relation $relation, $type)
{
if ($relation instanceof BelongsToMany) {
$table = $relation->getTable();
$fk = $relation->getForeignKey();
} else {
$table = $relation->getParent()->getTable();
$fk = $table . '.' . $parent->getForeignKey();
}
$pk = $parent->getQualifiedKeyName();
if (!$this->alreadyJoined($join = (new Join($type, $table))->on($fk, '=', $pk))) {
$this->query->joins[] = $join;
}
}
示例11: getQualifiedParentKeyName
/**
* Get the fully qualified parent key naem.
*
* @return string
*/
protected function getQualifiedParentKeyName()
{
return $this->parent->getQualifiedKeyName();
}
示例12: enforceOrderBy
/**
* Add a generic "order by" clause if the query doesn't already have one.
*
* @return void
*/
protected function enforceOrderBy()
{
if (empty($this->query->orders) && empty($this->query->unionOrders)) {
$this->orderBy($this->model->getQualifiedKeyName(), 'asc');
}
}
示例13: getRelationCountQuery
/**
* Add the constraints for a relationship count query.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function getRelationCountQuery(Builder $query)
{
$query->select(new Expression('count(*)'));
$key = $this->wrap($this->parent->getQualifiedKeyName());
return $query->where($this->getForeignKey(), '=', new Expression($key));
}
示例14: getKeyName
/**
* {@inheritdoc}
*/
protected function getKeyName()
{
return $this->model->getQualifiedKeyName();
}