Total Complexity | 4 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class StripeCustomersTileComponent extends Component |
||
11 | { |
||
12 | use WithPagination; |
||
|
|||
13 | |||
14 | /** @var string */ |
||
15 | public string $position; |
||
16 | |||
17 | /** @var string|null */ |
||
18 | public ?string $title; |
||
19 | |||
20 | public $perPage; |
||
21 | |||
22 | /** @var int|null */ |
||
23 | public ?int $refreshInSeconds; |
||
24 | |||
25 | public function mount(string $position, $perPage = 5, ?string $title = null, int $refreshInSeconds = null) |
||
26 | { |
||
27 | $this->position = $position; |
||
28 | $this->perPage = $perPage; |
||
29 | $this->title = $title; |
||
30 | $this->refreshInSeconds = $refreshInSeconds; |
||
31 | } |
||
32 | |||
33 | public function render() |
||
34 | { |
||
35 | $customers = collect(StripeCustomersStore::make()->getData()); |
||
36 | $paginator = $this->getPaginator($customers); |
||
37 | |||
38 | return view('dashboard-stripe-customers-tile::tile', [ |
||
39 | 'customers' => $customers->skip(($paginator->firstItem() ?? 1) - 1)->take($paginator->perPage()), |
||
40 | 'paginator' => $paginator, |
||
41 | 'refreshIntervalInSeconds' => $this->refreshInSeconds ?? config('dashboard.tiles.stripe.customers.refresh_interval_in_seconds') ?? 1800, |
||
42 | ]); |
||
43 | } |
||
44 | |||
45 | public function getPaginator(Collection $customers): LengthAwarePaginator |
||
48 | } |
||
49 | |||
50 | public function paginationView() |
||
55 |