6 months ago

Livewire Pagination, using mount()

Posted 6 months ago by WallyJ

I have followed the instructions in the docs here: https://laravel-livewire.com/docs/mount-method/

to get the results I want from my DB.

Livewire Controller


namespace App\Http\Livewire;

use Livewire\Component;
use App\Task;
use App\Contact;
use App\Contactnote;

class Contactshow extends Component

    public $contacts;
    public $tasktext;
    public $dealId;
    public $taskduedate;
    public $deal_id;

    public function mount($contacts)
        $this->contacts = $contacts;

    public function render()
        return view('livewire.contactshow');


View section of results:

<div class="col-md-12">
        <ul class="list-group">
            @foreach($this->contacts->contactnotes->sortByDesc('created_at') as $contactnote)
            <li class="list-group-item">
           {{$contactnote->created_at}} - {{$contactnote->contactnotetext}}

Results currently show correctly.

Now I want to paginate the results, but the paginate example in the docs:


does not use the mount() command in their example, so I am a bit confused. Not sure how to paginate at this point still using mount().

Please sign in or create an account to participate in this conversation.