1 | <?php |
||
14 | trait PaginatesQuery |
||
15 | { |
||
16 | /** |
||
17 | * Paginates the query. |
||
18 | * @see \Illuminate\Database\Eloquent\Builder::paginate() |
||
19 | * |
||
20 | * @param array|int|null $perPage per page options, refer to {@see getPerPageValue()} for more details. |
||
21 | * @param array $columns |
||
22 | * @return \Illuminate\Contracts\Pagination\Paginator |
||
23 | */ |
||
24 | public function pagination($perPage = null, $columns = ['*']) : Paginator |
||
28 | |||
29 | /** |
||
30 | * Paginate the query into a simple paginator. |
||
31 | * @see \Illuminate\Database\Eloquent\Builder::simplePaginate() |
||
32 | * |
||
33 | * @param array|int|null $perPage per page options, refer to {@see getPerPageValue()} for more details. |
||
34 | * @param array $columns |
||
35 | * @return \Illuminate\Contracts\Pagination\Paginator |
||
36 | */ |
||
37 | public function simplePagination($perPage = null, $columns = ['*']) : Paginator |
||
41 | |||
42 | /** |
||
43 | * Extracts per page value from the related HTTP request. |
||
44 | * |
||
45 | * @param array|int|null $options if not set - use default options, if scalar - use it as default per page value. |
||
46 | * If array - use as options with following keys: |
||
47 | * |
||
48 | * - 'default' - int, default per page value. |
||
49 | * - 'min' - int, min allowed per page value. |
||
50 | * - 'max' - int, max allowed per page value. |
||
51 | * |
||
52 | * @return int per page value. |
||
53 | */ |
||
54 | protected function getPerPageValue($options = null): int |
||
88 | |||
89 | /** |
||
90 | * @return string HTTP query parameter name for page number. |
||
91 | */ |
||
92 | protected function getPageParameterName() : string |
||
96 | |||
97 | /** |
||
98 | * @return int|null page number passed within associated HTTP request. |
||
99 | */ |
||
100 | protected function getPageValue() |
||
104 | } |
||
105 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.