Set a model instance for the model being queried.
public setModel ( |
||
$model |
/** * 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; }
/** * 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; }
/** * 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); }
/** * 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; }
/** * 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; }