Skip to content

Commit

Permalink
Split into separate trait
Browse files Browse the repository at this point in the history
  • Loading branch information
afonic committed Jan 27, 2025
1 parent 7b5c83c commit e480a71
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Http/Livewire/LivewireCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class LivewireCollection extends Component
{
use Hookable,
Traits\GenerateParams,
Traits\HandleEntriesCount,
Traits\HandleParams,
Traits\HandleTotalEntriesCount,
Traits\WithPagination;

public $params;
Expand Down
19 changes: 19 additions & 0 deletions src/Http/Livewire/Traits/HandleTotalEntriesCount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Reach\StatamicLivewireFilters\Http\Livewire\Traits;

use Statamic\Entries\EntryCollection;

trait HandleTotalEntriesCount
{
protected function countAllEntries(array $entries): int
{
if (isset($entries['pagination_total'])) {
return (int) $entries['pagination_total'];
} elseif ($entries['entries'] instanceof EntryCollection) {
return $entries['entries']->count();
}

return 0;
}
}

0 comments on commit e480a71

Please sign in to comment.