Skip to content

Instantly share code, notes, and snippets.

@Shaz3e
Created July 21, 2024 15:29
Show Gist options
  • Select an option

  • Save Shaz3e/fca61f81e21e4106941c58aa57ecf046 to your computer and use it in GitHub Desktop.

Select an option

Save Shaz3e/fca61f81e21e4106941c58aa57ecf046 to your computer and use it in GitHub Desktop.

Revisions

  1. Shaz3e created this gist Jul 21, 2024.
    22 changes: 22 additions & 0 deletions UserList.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    // In your livewire blade

    @php
    // Get the current page number, default to 1 if not set
    $currentPage = $dataSet->currentPage();
    // Get the number of items per page
    $perPage = $dataSet->perPage();
    // Calculate the starting index
    $i = ($currentPage - 1) * $perPage + 1;
    @endphp

    // In your livewire component
    public function render()
    {
    $query = User::query();

    $dataSet = $query->paginate(10);

    return view('livewire.user-list', [
    'dataSet' => $dataSet,
    ]);
    }