| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Digikraaft\StripePaymentsTile; |
||||
| 4 | |||||
| 5 | use Illuminate\Pagination\LengthAwarePaginator; |
||||
| 6 | use Illuminate\Support\Collection; |
||||
| 7 | use Livewire\Component; |
||||
| 8 | use Livewire\WithPagination; |
||||
| 9 | |||||
| 10 | class StripePaymentsTileComponent extends Component |
||||
| 11 | { |
||||
| 12 | use WithPagination; |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 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 | $payments = collect(StripePaymentsStore::make()->getData()); |
||||
| 36 | $paginator = $this->getPaginator($payments); |
||||
| 37 | |||||
| 38 | return view('dashboard-stripe-payments-tile::tile', [ |
||||
|
0 ignored issues
–
show
The function
view was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 39 | 'payments' => $payments->skip(($paginator->firstItem() ?? 1) - 1)->take($paginator->perPage()), |
||||
| 40 | 'paginator' => $paginator, |
||||
| 41 | 'refreshIntervalInSeconds' => $this->refreshInSeconds ?? config('dashboard.tiles.stripe.payments.refresh_interval_in_seconds') ?? 1800, |
||||
|
0 ignored issues
–
show
The function
config was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 42 | ]); |
||||
| 43 | } |
||||
| 44 | |||||
| 45 | public function getPaginator(Collection $payments): LengthAwarePaginator |
||||
| 46 | { |
||||
| 47 | return new LengthAwarePaginator($payments, $payments->count(), $this->perPage, $this->page); |
||||
| 48 | } |
||||
| 49 | |||||
| 50 | public function paginationView() |
||||
| 51 | { |
||||
| 52 | return 'dashboard-stripe-payments-tile::pagination'; |
||||
| 53 | } |
||||
| 54 | } |
||||
| 55 |