Lines n/a 0 / 0
Functions and Methods n/a 0 / 0
Classes and Traits n/a 0 / 0
Name Lines Functions and Methods CRAP Classes and Traits
FiltersQuery n/a 0 / 0 n/a 0 / 0 0 n/a 0 / 0
 orderBy n/a 0 / 0 n/a 0 / 0 0
 limit n/a 0 / 0 n/a 0 / 0 0
 offset n/a 0 / 0 n/a 0 / 0 0
 select n/a 0 / 0 n/a 0 / 0 0
 groupBy n/a 0 / 0 n/a 0 / 0 0
 having n/a 0 / 0 n/a 0 / 0 0
1<?php
2
3declare(strict_types=1);
4
5namespace BlueprintAU\Radiant\Concerns;
6
7use BlueprintAU\Radiant\Database\Query\Enums\SortDirection;
8use BlueprintAU\Radiant\Database\Query\Enums\WhereOperator;
9
10/**
11 * The shared filter vocabulary, instance-shaped.
12 *
13 * The where-family is not redefined here — this trait composes
14 * {@see FiltersWhere}. What it adds is the wrapper-only surface:
15 * `orderBy`/`limit`/`offset`/`select`/`groupBy`/`having` — abstract, not
16 * where-derivable. The natural consumers are objects that wrap a builder
17 * (a Relation holds one) and return a new wrapper per call.
18 */
19trait FiltersQuery
20{
21    use FiltersWhere;
22
23    /**
24     * Add an order-by clause.
25     *
26     * @param  string|\BlueprintAU\Radiant\Database\Query\Expression  $column
27     * @param  SortDirection|string  $direction
28     * @return static
29     */
30    abstract public function orderBy(string|\BlueprintAU\Radiant\Database\Query\Expression $column, SortDirection|string $direction = SortDirection::Asc): static;
31
32    /**
33     * Set the maximum number of rows to return.
34     *
35     * @param  int  $limit
36     * @return static
37     */
38    abstract public function limit(int $limit): static;
39
40    /**
41     * Set the number of rows to skip.
42     *
43     * @param  int  $offset
44     * @return static
45     */
46    abstract public function offset(int $offset): static;
47
48    /**
49     * Set an explicit column selection.
50     *
51     * @param  string|\BlueprintAU\Radiant\Database\Query\Expression|\BlueprintAU\Radiant\Database\Query\Aggregate  ...$columns
52     * @return static
53     */
54    abstract public function select(string|\BlueprintAU\Radiant\Database\Query\Expression|\BlueprintAU\Radiant\Database\Query\Aggregate ...$columns): static;
55
56    /**
57     * Group by columns (for aggregate + select combos).
58     *
59     * @param  string|array<int, string>  $columns
60     * @return static
61     */
62    abstract public function groupBy(string|array $columns): static;
63
64    /**
65     * Filter groups after aggregation (HAVING).
66     *
67     * @param  string|\BlueprintAU\Radiant\Database\Query\Expression|\BlueprintAU\Radiant\Database\Query\Aggregate  $column
68     * @param  WhereOperator|string  $operator
69     * @param  mixed  $value
70     * @return static
71     */
72    abstract public function having(string|\BlueprintAU\Radiant\Database\Query\Expression|\BlueprintAU\Radiant\Database\Query\Aggregate $column, WhereOperator|string $operator, mixed $value): static;
73}