本文整理汇总了PHP中Illuminate\Database\Eloquent\Builder::setModel方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::setModel方法的具体用法?PHP Builder::setModel怎么用?PHP Builder::setModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Builder
的用法示例。
在下文中一共展示了Builder::setModel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newRawQuery
/**
* Get a new query builder for the model's table.
*
* @return \Illuminate\Database\Eloquent\Builder;
*/
public function newRawQuery()
{
$builder = new Builder($this->newBaseQueryBuilder());
// Once we have the query builders, we will set the model instances
// so the builder can easily access any information it may need
// from the model while it is constructing and executing various
// queries against it.
$builder->setModel($this)->with($this->with);
return $builder;
}
示例2: newQuery
/**
* Overriding newQuery() to the custom PostBuilder with some intereting methods
*
* @param bool $excludeDeleted
* @return Corcel\PostBuilder
*/
public function newQuery($excludeDeleted = true)
{
$builder = new Builder($this->newBaseQueryBuilder());
$builder->setModel($this);
$builder->leftJoin('wp_term_taxonomy', 'wp_terms.term_id', '=', 'wp_term_taxonomy.term_id')->where('wp_term_taxonomy.taxonomy', '=', 'category')->select('wp_terms.*');
if ($excludeDeleted and $this->softDelete) {
$builder->whereNull($this->getQualifiedDeletedAtColumn());
}
return $builder;
}
示例3: setModel
/**
* Set a model instance for the model being queried.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @return $this
* @static
*/
public static function setModel($model)
{
return \Illuminate\Database\Eloquent\Builder::setModel($model);
}
示例4: newQuery
/**
* Get a new query builder for the model's table.
*
* @param bool $excludeDeleted
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function newQuery($excludeDeleted = true)
{
$builder = new Builder($this->newBaseQueryBuilder());
// Once we have the query builders, we will set the model instances so the
// builder can easily access any information it may need from the model
// while it is constructing and executing various queries against it.
$builder->setModel($this)->with($this->with);
if ($excludeDeleted and $this->softDelete) {
$builder->whereNull($this->getQualifiedDeletedAtColumn());
}
return $builder;
}
示例5: setModel
/**
* We automatically select all columns for the model to simplify some logic around select/addSelect
*
* @param \Illuminate\Database\Eloquent\Model $model
* @return $this
*/
public function setModel(Model $model)
{
parent::setModel($model);
$this->select('*');
return $this;
}