@@ -6,46 +6,46 @@ |
||
| 6 | 6 | |
| 7 | 7 | class EloquentDataProvider implements DataProviderInterface |
| 8 | 8 | { |
| 9 | - protected $query; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * EloquentDataProvider constructor. |
|
| 13 | - * @param Builder $query |
|
| 14 | - */ |
|
| 15 | - public function __construct(Builder $query) |
|
| 16 | - { |
|
| 17 | - $this->query = $query; |
|
| 18 | - } |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * @inheritdoc |
|
| 22 | - */ |
|
| 23 | - public function getCount(): int |
|
| 24 | - { |
|
| 25 | - return $this->query->count(); |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @inheritdoc |
|
| 30 | - */ |
|
| 31 | - public function getTotalPages(int $perPage): int |
|
| 32 | - { |
|
| 33 | - if ($perPage == 0) { |
|
| 34 | - return 1; |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - return ceil($this->getCount() / $perPage); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @inheritdoc |
|
| 42 | - */ |
|
| 43 | - public function getData(int $page, int $perPage) |
|
| 44 | - { |
|
| 45 | - if ($perPage == 0) { |
|
| 46 | - return $this->query->get(); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - return (clone $this->query)->paginate($perPage, ['*'], 'page', $page); |
|
| 50 | - } |
|
| 9 | + protected $query; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * EloquentDataProvider constructor. |
|
| 13 | + * @param Builder $query |
|
| 14 | + */ |
|
| 15 | + public function __construct(Builder $query) |
|
| 16 | + { |
|
| 17 | + $this->query = $query; |
|
| 18 | + } |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * @inheritdoc |
|
| 22 | + */ |
|
| 23 | + public function getCount(): int |
|
| 24 | + { |
|
| 25 | + return $this->query->count(); |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @inheritdoc |
|
| 30 | + */ |
|
| 31 | + public function getTotalPages(int $perPage): int |
|
| 32 | + { |
|
| 33 | + if ($perPage == 0) { |
|
| 34 | + return 1; |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + return ceil($this->getCount() / $perPage); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @inheritdoc |
|
| 42 | + */ |
|
| 43 | + public function getData(int $page, int $perPage) |
|
| 44 | + { |
|
| 45 | + if ($perPage == 0) { |
|
| 46 | + return $this->query->get(); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + return (clone $this->query)->paginate($perPage, ['*'], 'page', $page); |
|
| 50 | + } |
|
| 51 | 51 | } |
| 52 | 52 | \ No newline at end of file |