/** * Filter 检索数据时, 构造此字段的查询 * @param Table $query * @return Table */ public function filter(Table $query) : Table { $value = $this->getCurrentValue(); if ($this->range && is_array($value)) { $min = $value['min']; $max = $value['max']; switch (true) { case $min && $max: return $query->whereBetween($this->column(), $min, $max); case $min: return $query->whereGte($this->column(), $min); case $max: return $query->whereLte($this->column(), $max); default: return $query; } } else { return $query->whereEquals($this->column(), $value); } }
/** * Filter 检索数据时, 构造此字段的查询 * @param Table $query * @return Table */ public function filter(Table $query) : Table { if (!$this->relation()) { return $query; } return $query->whereEquals($query->original()->getModel()->getKeyName(), $this->getCurrentValue()); }
/** * Filter 检索数据时, 构造此字段的查询 * @param Table $query * @return Table */ public function filter(Table $query) : Table { return $query->whereEquals($this->column(), $this->getCurrentValue()); }