columns); } /** * Get query select columns list * * @return array */ public function getColumns() { return $this->columns; } /** * Execute the query as a "select" statement. * * @param array $columns * @return \Illuminate\Support\Collection */ public function get($columns = ['*']) { # Cache if (! is_null($this->cacheSeconds)) { return $this->getCached($columns); } return parent::get($columns); } /** * Get the SQL representation of the query. * * @return string */ public function toSql() { if ($this->hasTags()) { $hook = 'db.query.extend.' . $this->getTags('-'); if (bff::hooksAdded($hook)) { bff::hook($hook, $this); } return parent::toSql() . ' -- ' . $this->getTags(', '); } return parent::toSql(); } /** * Select crypted column * @param string $column * @param string $alias * @return $this */ public function selectCrypted($column, $alias = '') { $cmd = ' AES_DECRYPT(' . $column . ', ?) '; if ($alias) { $cmd .= ' as ' . $alias; } $this->selectRaw($cmd, [bff::database()->crypt()]); return $this; } /** * Add a basic where clause to the query. * @param mixed $column * @param mixed $operator * @param mixed $value * @param string $boolean * @return $this */ public function where($column, $operator = null, $value = null, $boolean = 'and') { if (is_array($column) && is_null($operator) && is_null($value)) { foreach ($column as $k => $v) { if (is_int($k)) { if (is_array($v) && count($v) == 3 && is_string($v[0]) && is_string($v[1]) && is_array($v[2])) { ## filter[] = ['id', 'in', [1, 2, 3]]; $lo = mb_strtolower($v[2]); if ($lo === 'in') { $this->whereIn($v[0], $v[2], $boolean); unset($column[$k]); } elseif ($lo === 'notin' || $lo === 'not in') { $this->whereNotIn($v[0], $v[2], $boolean); unset($column[$k]); } } elseif ($v instanceof Closure) { ## filter[] = function ($query) { ... } call_user_func($v, $this); unset($column[$k]); } } elseif (is_string($k)) { if (is_array($v)) { ## filter['id'] = [1,2,3]; $this->whereIn($k, $v, $boolean); unset($column[$k]); } } } } return parent::where($column, $operator, $value, $boolean); } }