Total Complexity | 3 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | trait WithPerPagePagination |
||
14 | { |
||
15 | use WithPagination; |
||
16 | |||
17 | /** |
||
18 | * Assign the perPage option from the session. |
||
19 | * |
||
20 | * @return void |
||
21 | * |
||
22 | * @throws ContainerExceptionInterface |
||
23 | * @throws NotFoundExceptionInterface |
||
24 | */ |
||
25 | public function mountWithPerPagePagination(): void |
||
26 | { |
||
27 | $this->perPage = session()->get('perPage', $this->perPage); |
||
|
|||
28 | } |
||
29 | |||
30 | /** |
||
31 | * Store in session the perPage option. |
||
32 | * |
||
33 | * @param mixed $value The value of the option perPage. |
||
34 | * |
||
35 | * @return void |
||
36 | */ |
||
37 | public function updatedPerPage(mixed $value): void |
||
38 | { |
||
39 | session()->put('perPage', $value); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Apply the pagination to the query. |
||
44 | * |
||
45 | * @param Builder $query The query to apply the pagination. |
||
46 | * |
||
47 | * @return LengthAwarePaginator |
||
48 | */ |
||
49 | public function applyPagination(Builder $query): LengthAwarePaginator |
||
52 | } |
||
53 | } |
||
54 |