diff --git a/src/Illuminate/Contracts/Database/Query/Builder.php b/src/Illuminate/Contracts/Database/Query/Builder.php new file mode 100644 index 000000000000..ec0d50ab2fcc --- /dev/null +++ b/src/Illuminate/Contracts/Database/Query/Builder.php @@ -0,0 +1,1079 @@ +callNamedScope($method, $parameters); } - if (in_array($method, $this->passthru)) { - return $this->toBase()->{$method}(...$parameters); - } - $this->forwardCallTo($this->query, $method, $parameters); return $this; diff --git a/src/Illuminate/Database/Eloquent/Concerns/DecoratesQueryBuilder.php b/src/Illuminate/Database/Eloquent/Concerns/DecoratesQueryBuilder.php new file mode 100644 index 000000000000..b22c5b831a14 --- /dev/null +++ b/src/Illuminate/Database/Eloquent/Concerns/DecoratesQueryBuilder.php @@ -0,0 +1,1227 @@ +forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function selectSub($query, $as) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function selectRaw($expression, array $bindings = []) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function fromSub($query, $as) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function fromRaw($expression, $bindings = []) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function addSelect($column) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function distinct() + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function from($table, $as = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function join($table, $first, $operator = null, $second = null, $type = 'inner', $where = false) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function joinWhere($table, $first, $operator, $second, $type = 'inner') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function joinSub($query, $as, $first, $operator = null, $second = null, $type = 'inner', $where = false) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function leftJoin($table, $first, $operator = null, $second = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function leftJoinWhere($table, $first, $operator, $second) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function leftJoinSub($query, $as, $first, $operator = null, $second = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function rightJoin($table, $first, $operator = null, $second = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function rightJoinWhere($table, $first, $operator, $second) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function rightJoinSub($query, $as, $first, $operator = null, $second = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function crossJoin($table, $first = null, $operator = null, $second = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function crossJoinSub($query, $as) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function mergeWheres($wheres, $bindings) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function where($column, $operator = null, $value = null, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function prepareValueAndOperator($value, $operator, $useDefault = false) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhere($column, $operator = null, $value = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereColumn($first, $operator = null, $second = null, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereColumn($first, $operator = null, $second = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereRaw($sql, $bindings = [], $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereRaw($sql, $bindings = []) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereIn($column, $values, $boolean = 'and', $not = false) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereIn($column, $values) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereNotIn($column, $values, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereNotIn($column, $values) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereIntegerInRaw($column, $values, $boolean = 'and', $not = false) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereIntegerInRaw($column, $values) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereIntegerNotInRaw($column, $values, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereIntegerNotInRaw($column, $values) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereNull($columns, $boolean = 'and', $not = false) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereNull($column) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereNotNull($columns, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereBetween($column, iterable $values, $boolean = 'and', $not = false) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereBetweenColumns($column, array $values, $boolean = 'and', $not = false) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereBetween($column, iterable $values) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereBetweenColumns($column, array $values) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereNotBetween($column, iterable $values, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereNotBetweenColumns($column, array $values, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereNotBetween($column, iterable $values) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereNotBetweenColumns($column, array $values) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereNotNull($column) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereDate($column, $operator, $value = null, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereDate($column, $operator, $value = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereTime($column, $operator, $value = null, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereTime($column, $operator, $value = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereDay($column, $operator, $value = null, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereDay($column, $operator, $value = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereMonth($column, $operator, $value = null, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereMonth($column, $operator, $value = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereYear($column, $operator, $value = null, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereYear($column, $operator, $value = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereNested(Closure $callback, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function addNestedWhereQuery($query, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereExists(Closure $callback, $boolean = 'and', $not = false) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereExists(Closure $callback, $not = false) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereNotExists(Closure $callback, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereNotExists(Closure $callback) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereRowValues($columns, $operator, $values, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereRowValues($columns, $operator, $values) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereJsonContains($column, $value, $boolean = 'and', $not = false) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereJsonContains($column, $value) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereJsonDoesntContain($column, $value, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereJsonDoesntContain($column, $value) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function whereJsonLength($column, $operator, $value = null, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orWhereJsonLength($column, $operator, $value = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function groupBy(...$groups) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function groupByRaw($sql, array $bindings = []) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function having($column, $operator = null, $value = null, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orHaving($column, $operator = null, $value = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function havingNull($columns, $boolean = 'and', $not = false) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * {@inheritdoc} + */ + public function orHavingNull($column) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function havingNotNull($columns, $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function orHavingNotNull($column) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function havingBetween($column, array $values, $boolean = 'and', $not = false) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function havingRaw($sql, array $bindings = [], $boolean = 'and') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function orHavingRaw($sql, array $bindings = []) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function orderBy($column, $direction = 'asc') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function orderByDesc($column) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function latest($column = 'created_at') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function oldest($column = 'created_at') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function inRandomOrder($seed = '') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function orderByRaw($sql, $bindings = []) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function skip($value) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function offset($value) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function take($value) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function limit($value) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function forPage($page, $perPage = 15) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function forPageBeforeId($perPage = 15, $lastId = 0, $column = 'id') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function forPageAfterId($perPage = 15, $lastId = 0, $column = 'id') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function reorder($column = null, $direction = 'asc') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function union($query, $all = false) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function unionAll($query) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function lock($value = true) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function lockForUpdate() + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function sharedLock() + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function toSql() + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function find($id, $columns = ['*']) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function value($column) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function get($columns = ['*']) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function cursor() + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function pluck($column, $key = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function implode($column, $glue = '') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function exists() + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function doesntExist() + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function existsOr(Closure $callback) + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function doesntExistOr(Closure $callback) + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function count($columns = '*') + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function min($column) + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function max($column) + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function sum($column) + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function avg($column) + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function average($column) + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function aggregate($function, $columns = ['*']) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function numericAggregate($function, $columns = ['*']) + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function insert(array $values) + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function insertOrIgnore(array $values) + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function insertGetId(array $values, $sequence = null) + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function insertUsing(array $columns, $query) + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function update(array $values) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function updateOrInsert(array $attributes, array $values = []) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function upsert(array $values, $uniqueBy, $update = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function increment($column, $amount = 1, array $extra = []) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function decrement($column, $amount = 1, array $extra = []) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function delete($id = null) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function truncate() + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function newQuery() + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function raw($value) + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function getBindings() + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function getRawBindings() + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function setBindings(array $bindings, $type = 'where') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function addBinding($value, $type = 'where') + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function mergeBindings(Builder $query) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function cleanBindings(array $bindings) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function getConnection() + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function getProcessor() + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function getGrammar() + { + return $this->toBase()->{__FUNCTION__}(...func_get_args()); + } + + /** + * @inheritdoc + */ + public function useWritePdo() + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function clone() + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function cloneWithout(array $properties) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * @inheritdoc + */ + public function cloneWithoutBindings(array $except) + { + return $this->forwardCallToQueryBuilder(__FUNCTION__, func_get_args()); + } + + /** + * Handle dynamic method calls to the query builder. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + return $this->forwardCallToQueryBuilder($method, $parameters); + } + + /** + * Forward the given method to the query builder. + * + * @param string $method + * @param array $parameters + * @return static|mixed + */ + protected function forwardCallToQueryBuilder($method, $parameters) + { + $result = $this->forwardCallTo($this->query, $method, $parameters); + + if ($result === $this->query) { + return $this; + } + + return $result; + } +} diff --git a/src/Illuminate/Database/Eloquent/Relations/MorphTo.php b/src/Illuminate/Database/Eloquent/Relations/MorphTo.php index 262741f30cfb..811853fb0c61 100644 --- a/src/Illuminate/Database/Eloquent/Relations/MorphTo.php +++ b/src/Illuminate/Database/Eloquent/Relations/MorphTo.php @@ -79,6 +79,46 @@ public function __construct(Builder $query, Model $parent, $foreignKey, $ownerKe parent::__construct($query, $parent, $foreignKey, $ownerKey, $relation); } + /** + * {@inheritdoc} + */ + public function select($columns = ['*']) + { + $this->macroBuffer[] = ['method' => 'select', 'parameters' => [$columns]]; + + return parent::select($columns); + } + + /** + * {@inheritdoc} + */ + public function selectRaw($expression, array $bindings = []) + { + $this->macroBuffer[] = ['method' => 'selectRaw', 'parameters' => [$expression, $bindings]]; + + return parent::selectRaw($expression, $bindings); + } + + /** + * {@inheritdoc} + */ + public function selectSub($query, $as) + { + $this->macroBuffer[] = ['method' => 'selectSub', 'parameters' => [$query, $as]]; + + return parent::selectSub($query, $as); + } + + /** + * {@inheritdoc} + */ + public function addSelect($column) + { + $this->macroBuffer[] = ['method' => 'addSelect', 'parameters' => [$column]]; + + return parent::addSelect($column); + } + /** * Set the constraints for an eager load of the relation. * @@ -377,7 +417,7 @@ public function __call($method, $parameters) try { $result = parent::__call($method, $parameters); - if (in_array($method, ['select', 'selectRaw', 'selectSub', 'addSelect', 'withoutGlobalScopes'])) { + if ($method === 'withoutGlobalScopes') { $this->macroBuffer[] = compact('method', 'parameters'); } diff --git a/src/Illuminate/Database/Eloquent/Relations/Relation.php b/src/Illuminate/Database/Eloquent/Relations/Relation.php index 7fe9f3e9fa82..e30f9875cfda 100755 --- a/src/Illuminate/Database/Eloquent/Relations/Relation.php +++ b/src/Illuminate/Database/Eloquent/Relations/Relation.php @@ -3,8 +3,10 @@ namespace Illuminate\Database\Eloquent\Relations; use Closure; +use Illuminate\Contracts\Database\Query\Builder as BuilderContract; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection; +use Illuminate\Database\Eloquent\Concerns\DecoratesQueryBuilder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\MultipleRecordsFoundException; @@ -13,13 +15,10 @@ use Illuminate\Support\Traits\ForwardsCalls; use Illuminate\Support\Traits\Macroable; -/** - * @mixin \Illuminate\Database\Eloquent\Builder - */ -abstract class Relation +abstract class Relation implements BuilderContract { - use ForwardsCalls, Macroable { - __call as macroCall; + use DecoratesQueryBuilder, ForwardsCalls, Macroable { + Macroable::__call as macroCall; } /** @@ -294,9 +293,21 @@ public function getQuery() /** * Get the base query builder driving the Eloquent builder. * + * @deprecated Use toBase() instead + * * @return \Illuminate\Database\Query\Builder */ public function getBaseQuery() + { + return $this->toBase(); + } + + /** + * Get a base query builder instance. + * + * @return \Illuminate\Database\Query\Builder + */ + public function toBase() { return $this->query->getQuery(); } diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index 925fb903a1e5..710e5c48f799 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -4,6 +4,7 @@ use Closure; use DateTimeInterface; +use Illuminate\Contracts\Database\Query\Builder as BuilderContract; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Database\Concerns\BuildsQueries; use Illuminate\Database\Concerns\ExplainsQueries; @@ -22,7 +23,7 @@ use InvalidArgumentException; use RuntimeException; -class Builder +class Builder implements BuilderContract { use BuildsQueries, ExplainsQueries, ForwardsCalls, Macroable { __call as macroCall; @@ -226,10 +227,7 @@ public function __construct(ConnectionInterface $connection, } /** - * Set the columns to be selected. - * - * @param array|mixed $columns - * @return $this + * {@inheritdoc} */ public function select($columns = ['*']) { @@ -249,13 +247,7 @@ public function select($columns = ['*']) } /** - * Add a subselect expression to the query. - * - * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder|string $query - * @param string $as - * @return $this - * - * @throws \InvalidArgumentException + * {@inheritdoc} */ public function selectSub($query, $as) { @@ -267,11 +259,7 @@ public function selectSub($query, $as) } /** - * Add a new "raw" select expression to the query. - * - * @param string $expression - * @param array $bindings - * @return $this + * {@inheritdoc} */ public function selectRaw($expression, array $bindings = []) { @@ -285,13 +273,7 @@ public function selectRaw($expression, array $bindings = []) } /** - * Makes "from" fetch from a subquery. - * - * @param \Closure|\Illuminate\Database\Query\Builder|string $query - * @param string $as - * @return $this - * - * @throws \InvalidArgumentException + * {@inheritdoc} */ public function fromSub($query, $as) { @@ -301,11 +283,7 @@ public function fromSub($query, $as) } /** - * Add a raw from clause to the query. - * - * @param string $expression - * @param mixed $bindings - * @return $this + * {@inheritdoc} */ public function fromRaw($expression, $bindings = []) { @@ -380,10 +358,7 @@ protected function prependDatabaseNameIfCrossDatabaseQuery($query) } /** - * Add a new select column to the query. - * - * @param array|mixed $column - * @return $this + * {@inheritdoc} */ public function addSelect($column) { @@ -405,9 +380,7 @@ public function addSelect($column) } /** - * Force the query to only return distinct results. - * - * @return $this + * {@inheritdoc} */ public function distinct() { @@ -423,11 +396,7 @@ public function distinct() } /** - * Set the table which the query is targeting. - * - * @param \Closure|\Illuminate\Database\Query\Builder|string $table - * @param string|null $as - * @return $this + * {@inheritdoc} */ public function from($table, $as = null) { @@ -441,15 +410,7 @@ public function from($table, $as = null) } /** - * Add a join clause to the query. - * - * @param string $table - * @param \Closure|string $first - * @param string|null $operator - * @param string|null $second - * @param string $type - * @param bool $where - * @return $this + * {@inheritdoc} */ public function join($table, $first, $operator = null, $second = null, $type = 'inner', $where = false) { @@ -481,14 +442,7 @@ public function join($table, $first, $operator = null, $second = null, $type = ' } /** - * Add a "join where" clause to the query. - * - * @param string $table - * @param \Closure|string $first - * @param string $operator - * @param string $second - * @param string $type - * @return $this + * {@inheritdoc} */ public function joinWhere($table, $first, $operator, $second, $type = 'inner') { @@ -496,18 +450,7 @@ public function joinWhere($table, $first, $operator, $second, $type = 'inner') } /** - * Add a subquery join clause to the query. - * - * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder|string $query - * @param string $as - * @param \Closure|string $first - * @param string|null $operator - * @param string|null $second - * @param string $type - * @param bool $where - * @return $this - * - * @throws \InvalidArgumentException + * {@inheritdoc} */ public function joinSub($query, $as, $first, $operator = null, $second = null, $type = 'inner', $where = false) { @@ -521,13 +464,7 @@ public function joinSub($query, $as, $first, $operator = null, $second = null, $ } /** - * Add a left join to the query. - * - * @param string $table - * @param \Closure|string $first - * @param string|null $operator - * @param string|null $second - * @return $this + * {@inheritdoc} */ public function leftJoin($table, $first, $operator = null, $second = null) { @@ -535,13 +472,7 @@ public function leftJoin($table, $first, $operator = null, $second = null) } /** - * Add a "join where" clause to the query. - * - * @param string $table - * @param \Closure|string $first - * @param string $operator - * @param string $second - * @return $this + * {@inheritdoc} */ public function leftJoinWhere($table, $first, $operator, $second) { @@ -549,14 +480,7 @@ public function leftJoinWhere($table, $first, $operator, $second) } /** - * Add a subquery left join to the query. - * - * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder|string $query - * @param string $as - * @param \Closure|string $first - * @param string|null $operator - * @param string|null $second - * @return $this + * {@inheritdoc} */ public function leftJoinSub($query, $as, $first, $operator = null, $second = null) { @@ -564,13 +488,7 @@ public function leftJoinSub($query, $as, $first, $operator = null, $second = nul } /** - * Add a right join to the query. - * - * @param string $table - * @param \Closure|string $first - * @param string|null $operator - * @param string|null $second - * @return $this + * {@inheritdoc} */ public function rightJoin($table, $first, $operator = null, $second = null) { @@ -578,13 +496,7 @@ public function rightJoin($table, $first, $operator = null, $second = null) } /** - * Add a "right join where" clause to the query. - * - * @param string $table - * @param \Closure|string $first - * @param string $operator - * @param string $second - * @return $this + * {@inheritdoc} */ public function rightJoinWhere($table, $first, $operator, $second) { @@ -592,14 +504,7 @@ public function rightJoinWhere($table, $first, $operator, $second) } /** - * Add a subquery right join to the query. - * - * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder|string $query - * @param string $as - * @param \Closure|string $first - * @param string|null $operator - * @param string|null $second - * @return $this + * {@inheritdoc} */ public function rightJoinSub($query, $as, $first, $operator = null, $second = null) { @@ -607,13 +512,7 @@ public function rightJoinSub($query, $as, $first, $operator = null, $second = nu } /** - * Add a "cross join" clause to the query. - * - * @param string $table - * @param \Closure|string|null $first - * @param string|null $operator - * @param string|null $second - * @return $this + * {@inheritdoc} */ public function crossJoin($table, $first = null, $operator = null, $second = null) { @@ -627,11 +526,7 @@ public function crossJoin($table, $first = null, $operator = null, $second = nul } /** - * Add a subquery cross join to the query. - * - * @param \Closure|\Illuminate\Database\Query\Builder|string $query - * @param string $as - * @return $this + * {@inheritdoc} */ public function crossJoinSub($query, $as) { @@ -660,11 +555,7 @@ protected function newJoinClause(self $parentQuery, $type, $table) } /** - * Merge an array of where clauses and bindings. - * - * @param array $wheres - * @param array $bindings - * @return void + * {@inheritdoc} */ public function mergeWheres($wheres, $bindings) { @@ -673,16 +564,12 @@ public function mergeWheres($wheres, $bindings) $this->bindings['where'] = array_values( array_merge($this->bindings['where'], (array) $bindings) ); + + return $this; } /** - * Add a basic where clause to the query. - * - * @param \Closure|string|array $column - * @param mixed $operator - * @param mixed $value - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function where($column, $operator = null, $value = null, $boolean = 'and') { @@ -787,14 +674,7 @@ protected function addArrayOfWheres($column, $boolean, $method = 'where') } /** - * Prepare the value and operator for a where clause. - * - * @param string $value - * @param string $operator - * @param bool $useDefault - * @return array - * - * @throws \InvalidArgumentException + * {@inheritdoc} */ public function prepareValueAndOperator($value, $operator, $useDefault = false) { @@ -835,12 +715,7 @@ protected function invalidOperator($operator) } /** - * Add an "or where" clause to the query. - * - * @param \Closure|string|array $column - * @param mixed $operator - * @param mixed $value - * @return $this + * {@inheritdoc} */ public function orWhere($column, $operator = null, $value = null) { @@ -852,13 +727,7 @@ public function orWhere($column, $operator = null, $value = null) } /** - * Add a "where" clause comparing two columns to the query. - * - * @param string|array $first - * @param string|null $operator - * @param string|null $second - * @param string|null $boolean - * @return $this + * {@inheritdoc} */ public function whereColumn($first, $operator = null, $second = null, $boolean = 'and') { @@ -889,12 +758,7 @@ public function whereColumn($first, $operator = null, $second = null, $boolean = } /** - * Add an "or where" clause comparing two columns to the query. - * - * @param string|array $first - * @param string|null $operator - * @param string|null $second - * @return $this + * {@inheritdoc} */ public function orWhereColumn($first, $operator = null, $second = null) { @@ -902,12 +766,7 @@ public function orWhereColumn($first, $operator = null, $second = null) } /** - * Add a raw where clause to the query. - * - * @param string $sql - * @param mixed $bindings - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function whereRaw($sql, $bindings = [], $boolean = 'and') { @@ -919,11 +778,7 @@ public function whereRaw($sql, $bindings = [], $boolean = 'and') } /** - * Add a raw or where clause to the query. - * - * @param string $sql - * @param mixed $bindings - * @return $this + * {@inheritdoc} */ public function orWhereRaw($sql, $bindings = []) { @@ -931,13 +786,7 @@ public function orWhereRaw($sql, $bindings = []) } /** - * Add a "where in" clause to the query. - * - * @param string $column - * @param mixed $values - * @param string $boolean - * @param bool $not - * @return $this + * {@inheritdoc} */ public function whereIn($column, $values, $boolean = 'and', $not = false) { @@ -972,11 +821,7 @@ public function whereIn($column, $values, $boolean = 'and', $not = false) } /** - * Add an "or where in" clause to the query. - * - * @param string $column - * @param mixed $values - * @return $this + * {@inheritdoc} */ public function orWhereIn($column, $values) { @@ -984,12 +829,7 @@ public function orWhereIn($column, $values) } /** - * Add a "where not in" clause to the query. - * - * @param string $column - * @param mixed $values - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function whereNotIn($column, $values, $boolean = 'and') { @@ -997,11 +837,7 @@ public function whereNotIn($column, $values, $boolean = 'and') } /** - * Add an "or where not in" clause to the query. - * - * @param string $column - * @param mixed $values - * @return $this + * {@inheritdoc} */ public function orWhereNotIn($column, $values) { @@ -1009,13 +845,7 @@ public function orWhereNotIn($column, $values) } /** - * Add a "where in raw" clause for integer values to the query. - * - * @param string $column - * @param \Illuminate\Contracts\Support\Arrayable|array $values - * @param string $boolean - * @param bool $not - * @return $this + * {@inheritdoc} */ public function whereIntegerInRaw($column, $values, $boolean = 'and', $not = false) { @@ -1035,11 +865,7 @@ public function whereIntegerInRaw($column, $values, $boolean = 'and', $not = fal } /** - * Add an "or where in raw" clause for integer values to the query. - * - * @param string $column - * @param \Illuminate\Contracts\Support\Arrayable|array $values - * @return $this + * {@inheritdoc} */ public function orWhereIntegerInRaw($column, $values) { @@ -1047,12 +873,7 @@ public function orWhereIntegerInRaw($column, $values) } /** - * Add a "where not in raw" clause for integer values to the query. - * - * @param string $column - * @param \Illuminate\Contracts\Support\Arrayable|array $values - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function whereIntegerNotInRaw($column, $values, $boolean = 'and') { @@ -1060,11 +881,7 @@ public function whereIntegerNotInRaw($column, $values, $boolean = 'and') } /** - * Add an "or where not in raw" clause for integer values to the query. - * - * @param string $column - * @param \Illuminate\Contracts\Support\Arrayable|array $values - * @return $this + * {@inheritdoc} */ public function orWhereIntegerNotInRaw($column, $values) { @@ -1072,12 +889,7 @@ public function orWhereIntegerNotInRaw($column, $values) } /** - * Add a "where null" clause to the query. - * - * @param string|array $columns - * @param string $boolean - * @param bool $not - * @return $this + * {@inheritdoc} */ public function whereNull($columns, $boolean = 'and', $not = false) { @@ -1091,10 +903,7 @@ public function whereNull($columns, $boolean = 'and', $not = false) } /** - * Add an "or where null" clause to the query. - * - * @param string|array $column - * @return $this + * {@inheritdoc} */ public function orWhereNull($column) { @@ -1102,11 +911,7 @@ public function orWhereNull($column) } /** - * Add a "where not null" clause to the query. - * - * @param string|array $columns - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function whereNotNull($columns, $boolean = 'and') { @@ -1114,13 +919,7 @@ public function whereNotNull($columns, $boolean = 'and') } /** - * Add a where between statement to the query. - * - * @param string|\Illuminate\Database\Query\Expression $column - * @param iterable $values - * @param string $boolean - * @param bool $not - * @return $this + * {@inheritdoc} */ public function whereBetween($column, iterable $values, $boolean = 'and', $not = false) { @@ -1134,13 +933,7 @@ public function whereBetween($column, iterable $values, $boolean = 'and', $not = } /** - * Add a where between statement using columns to the query. - * - * @param string $column - * @param array $values - * @param string $boolean - * @param bool $not - * @return $this + * {@inheritdoc} */ public function whereBetweenColumns($column, array $values, $boolean = 'and', $not = false) { @@ -1152,11 +945,7 @@ public function whereBetweenColumns($column, array $values, $boolean = 'and', $n } /** - * Add an or where between statement to the query. - * - * @param string $column - * @param iterable $values - * @return $this + * {@inheritdoc} */ public function orWhereBetween($column, iterable $values) { @@ -1164,11 +953,7 @@ public function orWhereBetween($column, iterable $values) } /** - * Add an or where between statement using columns to the query. - * - * @param string $column - * @param array $values - * @return $this + * {@inheritdoc} */ public function orWhereBetweenColumns($column, array $values) { @@ -1176,12 +961,7 @@ public function orWhereBetweenColumns($column, array $values) } /** - * Add a where not between statement to the query. - * - * @param string $column - * @param iterable $values - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function whereNotBetween($column, iterable $values, $boolean = 'and') { @@ -1189,12 +969,7 @@ public function whereNotBetween($column, iterable $values, $boolean = 'and') } /** - * Add a where not between statement using columns to the query. - * - * @param string $column - * @param array $values - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function whereNotBetweenColumns($column, array $values, $boolean = 'and') { @@ -1202,11 +977,7 @@ public function whereNotBetweenColumns($column, array $values, $boolean = 'and') } /** - * Add an or where not between statement to the query. - * - * @param string $column - * @param iterable $values - * @return $this + * {@inheritdoc} */ public function orWhereNotBetween($column, iterable $values) { @@ -1214,11 +985,7 @@ public function orWhereNotBetween($column, iterable $values) } /** - * Add an or where not between statement using columns to the query. - * - * @param string $column - * @param array $values - * @return $this + * {@inheritdoc} */ public function orWhereNotBetweenColumns($column, array $values) { @@ -1226,10 +993,7 @@ public function orWhereNotBetweenColumns($column, array $values) } /** - * Add an "or where not null" clause to the query. - * - * @param string $column - * @return $this + * {@inheritdoc} */ public function orWhereNotNull($column) { @@ -1237,13 +1001,7 @@ public function orWhereNotNull($column) } /** - * Add a "where date" statement to the query. - * - * @param string $column - * @param string $operator - * @param \DateTimeInterface|string|null $value - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function whereDate($column, $operator, $value = null, $boolean = 'and') { @@ -1261,12 +1019,7 @@ public function whereDate($column, $operator, $value = null, $boolean = 'and') } /** - * Add an "or where date" statement to the query. - * - * @param string $column - * @param string $operator - * @param \DateTimeInterface|string|null $value - * @return $this + * {@inheritdoc} */ public function orWhereDate($column, $operator, $value = null) { @@ -1278,13 +1031,7 @@ public function orWhereDate($column, $operator, $value = null) } /** - * Add a "where time" statement to the query. - * - * @param string $column - * @param string $operator - * @param \DateTimeInterface|string|null $value - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function whereTime($column, $operator, $value = null, $boolean = 'and') { @@ -1302,12 +1049,7 @@ public function whereTime($column, $operator, $value = null, $boolean = 'and') } /** - * Add an "or where time" statement to the query. - * - * @param string $column - * @param string $operator - * @param \DateTimeInterface|string|null $value - * @return $this + * {@inheritdoc} */ public function orWhereTime($column, $operator, $value = null) { @@ -1319,13 +1061,7 @@ public function orWhereTime($column, $operator, $value = null) } /** - * Add a "where day" statement to the query. - * - * @param string $column - * @param string $operator - * @param \DateTimeInterface|string|null $value - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function whereDay($column, $operator, $value = null, $boolean = 'and') { @@ -1347,12 +1083,7 @@ public function whereDay($column, $operator, $value = null, $boolean = 'and') } /** - * Add an "or where day" statement to the query. - * - * @param string $column - * @param string $operator - * @param \DateTimeInterface|string|null $value - * @return $this + * {@inheritdoc} */ public function orWhereDay($column, $operator, $value = null) { @@ -1364,13 +1095,7 @@ public function orWhereDay($column, $operator, $value = null) } /** - * Add a "where month" statement to the query. - * - * @param string $column - * @param string $operator - * @param \DateTimeInterface|string|null $value - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function whereMonth($column, $operator, $value = null, $boolean = 'and') { @@ -1392,12 +1117,7 @@ public function whereMonth($column, $operator, $value = null, $boolean = 'and') } /** - * Add an "or where month" statement to the query. - * - * @param string $column - * @param string $operator - * @param \DateTimeInterface|string|null $value - * @return $this + * {@inheritdoc} */ public function orWhereMonth($column, $operator, $value = null) { @@ -1409,13 +1129,7 @@ public function orWhereMonth($column, $operator, $value = null) } /** - * Add a "where year" statement to the query. - * - * @param string $column - * @param string $operator - * @param \DateTimeInterface|string|int|null $value - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function whereYear($column, $operator, $value = null, $boolean = 'and') { @@ -1433,12 +1147,7 @@ public function whereYear($column, $operator, $value = null, $boolean = 'and') } /** - * Add an "or where year" statement to the query. - * - * @param string $column - * @param string $operator - * @param \DateTimeInterface|string|int|null $value - * @return $this + * {@inheritdoc} */ public function orWhereYear($column, $operator, $value = null) { @@ -1471,11 +1180,7 @@ protected function addDateBasedWhere($type, $column, $operator, $value, $boolean } /** - * Add a nested where statement to the query. - * - * @param \Closure $callback - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function whereNested(Closure $callback, $boolean = 'and') { @@ -1495,11 +1200,7 @@ public function forNestedWhere() } /** - * Add another query builder as a nested where to the query builder. - * - * @param \Illuminate\Database\Query\Builder $query - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function addNestedWhereQuery($query, $boolean = 'and') { @@ -1542,12 +1243,7 @@ protected function whereSub($column, $operator, Closure $callback, $boolean) } /** - * Add an exists clause to the query. - * - * @param \Closure $callback - * @param string $boolean - * @param bool $not - * @return $this + * {@inheritdoc} */ public function whereExists(Closure $callback, $boolean = 'and', $not = false) { @@ -1562,11 +1258,7 @@ public function whereExists(Closure $callback, $boolean = 'and', $not = false) } /** - * Add an or exists clause to the query. - * - * @param \Closure $callback - * @param bool $not - * @return $this + * {@inheritdoc} */ public function orWhereExists(Closure $callback, $not = false) { @@ -1574,11 +1266,7 @@ public function orWhereExists(Closure $callback, $not = false) } /** - * Add a where not exists clause to the query. - * - * @param \Closure $callback - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function whereNotExists(Closure $callback, $boolean = 'and') { @@ -1586,10 +1274,7 @@ public function whereNotExists(Closure $callback, $boolean = 'and') } /** - * Add a where not exists clause to the query. - * - * @param \Closure $callback - * @return $this + * {@inheritdoc} */ public function orWhereNotExists(Closure $callback) { @@ -1616,15 +1301,7 @@ public function addWhereExistsQuery(self $query, $boolean = 'and', $not = false) } /** - * Adds a where condition using row values. - * - * @param array $columns - * @param string $operator - * @param array $values - * @param string $boolean - * @return $this - * - * @throws \InvalidArgumentException + * {@inheritdoc} */ public function whereRowValues($columns, $operator, $values, $boolean = 'and') { @@ -1642,12 +1319,7 @@ public function whereRowValues($columns, $operator, $values, $boolean = 'and') } /** - * Adds an or where condition using row values. - * - * @param array $columns - * @param string $operator - * @param array $values - * @return $this + * {@inheritdoc} */ public function orWhereRowValues($columns, $operator, $values) { @@ -1655,13 +1327,7 @@ public function orWhereRowValues($columns, $operator, $values) } /** - * Add a "where JSON contains" clause to the query. - * - * @param string $column - * @param mixed $value - * @param string $boolean - * @param bool $not - * @return $this + * {@inheritdoc} */ public function whereJsonContains($column, $value, $boolean = 'and', $not = false) { @@ -1677,11 +1343,7 @@ public function whereJsonContains($column, $value, $boolean = 'and', $not = fals } /** - * Add an "or where JSON contains" clause to the query. - * - * @param string $column - * @param mixed $value - * @return $this + * {@inheritdoc} */ public function orWhereJsonContains($column, $value) { @@ -1689,12 +1351,7 @@ public function orWhereJsonContains($column, $value) } /** - * Add a "where JSON not contains" clause to the query. - * - * @param string $column - * @param mixed $value - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function whereJsonDoesntContain($column, $value, $boolean = 'and') { @@ -1702,11 +1359,7 @@ public function whereJsonDoesntContain($column, $value, $boolean = 'and') } /** - * Add an "or where JSON not contains" clause to the query. - * - * @param string $column - * @param mixed $value - * @return $this + * {@inheritdoc} */ public function orWhereJsonDoesntContain($column, $value) { @@ -1714,13 +1367,7 @@ public function orWhereJsonDoesntContain($column, $value) } /** - * Add a "where JSON length" clause to the query. - * - * @param string $column - * @param mixed $operator - * @param mixed $value - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function whereJsonLength($column, $operator, $value = null, $boolean = 'and') { @@ -1740,12 +1387,7 @@ public function whereJsonLength($column, $operator, $value = null, $boolean = 'a } /** - * Add an "or where JSON length" clause to the query. - * - * @param string $column - * @param mixed $operator - * @param mixed $value - * @return $this + * {@inheritdoc} */ public function orWhereJsonLength($column, $operator, $value = null) { @@ -1819,10 +1461,7 @@ protected function addDynamic($segment, $connector, $parameters, $index) } /** - * Add a "group by" clause to the query. - * - * @param array|string ...$groups - * @return $this + * {@inheritdoc} */ public function groupBy(...$groups) { @@ -1837,11 +1476,7 @@ public function groupBy(...$groups) } /** - * Add a raw groupBy clause to the query. - * - * @param string $sql - * @param array $bindings - * @return $this + * {@inheritdoc} */ public function groupByRaw($sql, array $bindings = []) { @@ -1853,13 +1488,7 @@ public function groupByRaw($sql, array $bindings = []) } /** - * Add a "having" clause to the query. - * - * @param string $column - * @param string|null $operator - * @param string|null $value - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function having($column, $operator = null, $value = null, $boolean = 'and') { @@ -1889,12 +1518,7 @@ public function having($column, $operator = null, $value = null, $boolean = 'and } /** - * Add an "or having" clause to the query. - * - * @param string $column - * @param string|null $operator - * @param string|null $value - * @return $this + * {@inheritdoc} */ public function orHaving($column, $operator = null, $value = null) { @@ -1906,12 +1530,7 @@ public function orHaving($column, $operator = null, $value = null) } /** - * Add a "having null" clause to the query. - * - * @param string|array $columns - * @param string $boolean - * @param bool $not - * @return $this + * {@inheritdoc} */ public function havingNull($columns, $boolean = 'and', $not = false) { @@ -1925,10 +1544,7 @@ public function havingNull($columns, $boolean = 'and', $not = false) } /** - * Add an "or having null" clause to the query. - * - * @param string $column - * @return $this + * {@inheritdoc} */ public function orHavingNull($column) { @@ -1936,11 +1552,7 @@ public function orHavingNull($column) } /** - * Add a "having not null" clause to the query. - * - * @param string|array $columns - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function havingNotNull($columns, $boolean = 'and') { @@ -1948,10 +1560,7 @@ public function havingNotNull($columns, $boolean = 'and') } /** - * Add an "or having not null" clause to the query. - * - * @param string $column - * @return $this + * {@inheritdoc} */ public function orHavingNotNull($column) { @@ -1959,13 +1568,7 @@ public function orHavingNotNull($column) } /** - * Add a "having between " clause to the query. - * - * @param string $column - * @param array $values - * @param string $boolean - * @param bool $not - * @return $this + * {@inheritdoc} */ public function havingBetween($column, array $values, $boolean = 'and', $not = false) { @@ -1979,12 +1582,7 @@ public function havingBetween($column, array $values, $boolean = 'and', $not = f } /** - * Add a raw having clause to the query. - * - * @param string $sql - * @param array $bindings - * @param string $boolean - * @return $this + * {@inheritdoc} */ public function havingRaw($sql, array $bindings = [], $boolean = 'and') { @@ -1998,11 +1596,7 @@ public function havingRaw($sql, array $bindings = [], $boolean = 'and') } /** - * Add a raw or having clause to the query. - * - * @param string $sql - * @param array $bindings - * @return $this + * {@inheritdoc} */ public function orHavingRaw($sql, array $bindings = []) { @@ -2010,13 +1604,7 @@ public function orHavingRaw($sql, array $bindings = []) } /** - * Add an "order by" clause to the query. - * - * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Query\Expression|string $column - * @param string $direction - * @return $this - * - * @throws \InvalidArgumentException + * {@inheritdoc} */ public function orderBy($column, $direction = 'asc') { @@ -2043,10 +1631,7 @@ public function orderBy($column, $direction = 'asc') } /** - * Add a descending "order by" clause to the query. - * - * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Query\Expression|string $column - * @return $this + * {@inheritdoc} */ public function orderByDesc($column) { @@ -2054,10 +1639,7 @@ public function orderByDesc($column) } /** - * Add an "order by" clause for a timestamp to the query. - * - * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Query\Expression|string $column - * @return $this + * {@inheritdoc} */ public function latest($column = 'created_at') { @@ -2065,10 +1647,7 @@ public function latest($column = 'created_at') } /** - * Add an "order by" clause for a timestamp to the query. - * - * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Query\Expression|string $column - * @return $this + * {@inheritdoc} */ public function oldest($column = 'created_at') { @@ -2076,10 +1655,7 @@ public function oldest($column = 'created_at') } /** - * Put the query's results in random order. - * - * @param string $seed - * @return $this + * {@inheritdoc} */ public function inRandomOrder($seed = '') { @@ -2087,11 +1663,7 @@ public function inRandomOrder($seed = '') } /** - * Add a raw "order by" clause to the query. - * - * @param string $sql - * @param array $bindings - * @return $this + * {@inheritdoc} */ public function orderByRaw($sql, $bindings = []) { @@ -2105,10 +1677,7 @@ public function orderByRaw($sql, $bindings = []) } /** - * Alias to set the "offset" value of the query. - * - * @param int $value - * @return $this + * {@inheritdoc} */ public function skip($value) { @@ -2116,10 +1685,7 @@ public function skip($value) } /** - * Set the "offset" value of the query. - * - * @param int $value - * @return $this + * {@inheritdoc} */ public function offset($value) { @@ -2131,10 +1697,7 @@ public function offset($value) } /** - * Alias to set the "limit" value of the query. - * - * @param int $value - * @return $this + * {@inheritdoc} */ public function take($value) { @@ -2142,10 +1705,7 @@ public function take($value) } /** - * Set the "limit" value of the query. - * - * @param int $value - * @return $this + * {@inheritdoc} */ public function limit($value) { @@ -2159,11 +1719,7 @@ public function limit($value) } /** - * Set the limit and offset for a given page. - * - * @param int $page - * @param int $perPage - * @return $this + * @inheritdoc */ public function forPage($page, $perPage = 15) { @@ -2171,12 +1727,7 @@ public function forPage($page, $perPage = 15) } /** - * Constrain the query to the previous "page" of results before a given ID. - * - * @param int $perPage - * @param int|null $lastId - * @param string $column - * @return $this + * @inheritdoc */ public function forPageBeforeId($perPage = 15, $lastId = 0, $column = 'id') { @@ -2191,12 +1742,7 @@ public function forPageBeforeId($perPage = 15, $lastId = 0, $column = 'id') } /** - * Constrain the query to the next "page" of results after a given ID. - * - * @param int $perPage - * @param int|null $lastId - * @param string $column - * @return $this + * @inheritdoc */ public function forPageAfterId($perPage = 15, $lastId = 0, $column = 'id') { @@ -2211,11 +1757,7 @@ public function forPageAfterId($perPage = 15, $lastId = 0, $column = 'id') } /** - * Remove all existing orders and optionally add a new order. - * - * @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Query\Expression|string|null $column - * @param string $direction - * @return $this + * @inheritdoc */ public function reorder($column = null, $direction = 'asc') { @@ -2247,11 +1789,7 @@ protected function removeExistingOrdersFor($column) } /** - * Add a union statement to the query. - * - * @param \Illuminate\Database\Query\Builder|\Closure $query - * @param bool $all - * @return $this + * @inheritdoc */ public function union($query, $all = false) { @@ -2267,10 +1805,7 @@ public function union($query, $all = false) } /** - * Add a union all statement to the query. - * - * @param \Illuminate\Database\Query\Builder|\Closure $query - * @return $this + * @inheritdoc */ public function unionAll($query) { @@ -2278,10 +1813,7 @@ public function unionAll($query) } /** - * Lock the selected rows in the table. - * - * @param string|bool $value - * @return $this + * @inheritdoc */ public function lock($value = true) { @@ -2295,9 +1827,7 @@ public function lock($value = true) } /** - * Lock the selected rows in the table for updating. - * - * @return \Illuminate\Database\Query\Builder + * @inheritdoc */ public function lockForUpdate() { @@ -2305,9 +1835,7 @@ public function lockForUpdate() } /** - * Share lock the selected rows in the table. - * - * @return \Illuminate\Database\Query\Builder + * @inheritdoc */ public function sharedLock() { @@ -3202,9 +2730,7 @@ public function truncate() } /** - * Get a new instance of the query builder. - * - * @return \Illuminate\Database\Query\Builder + * @inheritdoc */ public function newQuery() { @@ -3222,10 +2748,7 @@ protected function forSubQuery() } /** - * Create a raw database expression. - * - * @param mixed $value - * @return \Illuminate\Database\Query\Expression + * @inheritdoc */ public function raw($value) { @@ -3233,9 +2756,7 @@ public function raw($value) } /** - * Get the current query value bindings in a flattened array. - * - * @return array + * @inheritdoc */ public function getBindings() { @@ -3243,9 +2764,7 @@ public function getBindings() } /** - * Get the raw array of bindings. - * - * @return array + * @inheritdoc */ public function getRawBindings() { @@ -3253,13 +2772,7 @@ public function getRawBindings() } /** - * Set the bindings on the query builder. - * - * @param array $bindings - * @param string $type - * @return $this - * - * @throws \InvalidArgumentException + * @inheritdoc */ public function setBindings(array $bindings, $type = 'where') { @@ -3273,13 +2786,7 @@ public function setBindings(array $bindings, $type = 'where') } /** - * Add a binding to the query. - * - * @param mixed $value - * @param string $type - * @return $this - * - * @throws \InvalidArgumentException + * @inheritdoc */ public function addBinding($value, $type = 'where') { @@ -3297,23 +2804,17 @@ public function addBinding($value, $type = 'where') } /** - * Merge an array of bindings into our bindings. - * - * @param \Illuminate\Database\Query\Builder $query - * @return $this + * @inheritdoc */ - public function mergeBindings(self $query) + public function mergeBindings(BuilderContract $query) { - $this->bindings = array_merge_recursive($this->bindings, $query->bindings); + $this->bindings = array_merge_recursive($this->bindings, $query->getRawBindings()); return $this; } /** - * Remove all of the expressions from a list of bindings. - * - * @param array $bindings - * @return array + * @inheritdoc */ public function cleanBindings(array $bindings) { @@ -3344,9 +2845,7 @@ protected function defaultKeyName() } /** - * Get the database connection instance. - * - * @return \Illuminate\Database\ConnectionInterface + * @inheritdoc */ public function getConnection() { @@ -3354,9 +2853,7 @@ public function getConnection() } /** - * Get the database query processor instance. - * - * @return \Illuminate\Database\Query\Processors\Processor + * @inheritdoc */ public function getProcessor() { @@ -3364,9 +2861,7 @@ public function getProcessor() } /** - * Get the query grammar instance. - * - * @return \Illuminate\Database\Query\Grammars\Grammar + * @inheritdoc */ public function getGrammar() { @@ -3374,9 +2869,7 @@ public function getGrammar() } /** - * Use the write pdo for query. - * - * @return $this + * @inheritdoc */ public function useWritePdo() { @@ -3400,9 +2893,7 @@ protected function isQueryable($value) } /** - * Clone the query. - * - * @return static + * @inheritdoc */ public function clone() { @@ -3410,10 +2901,7 @@ public function clone() } /** - * Clone the query without the given properties. - * - * @param array $properties - * @return static + * @inheritdoc */ public function cloneWithout(array $properties) { @@ -3425,10 +2913,7 @@ public function cloneWithout(array $properties) } /** - * Clone the query without the given bindings. - * - * @param array $except - * @return static + * @inheritdoc */ public function cloneWithoutBindings(array $except) {