rjrocks's avatar

Can't display the pagination links in blade file

This is livewire file:

0 likes
14 replies
tykus's avatar

Please format your code correctly using triple backticks to wrap code snippets

rjrocks's avatar

@shaungbhone tried that, dd() showing the pagination links but can not display on blade view.

jlrdw's avatar

Probably expecting an object. Just my opinion. You seem to be using an array, unless I missed something, that's a lot of code to look over.

rjrocks's avatar

@jlrdw ofcourse you are right, but I do not know that how to show the pagination links in blade file.

rjrocks's avatar

@jlrdw Tried with using collection but get another error for count function on blade file, and for the helper function, I don't know how to do it. Can you show me ?

jlrdw's avatar

In the link, see the second example count is being dealt with.

rjrocks's avatar

@jlrdw Tried but can not get the actual point, can you show me example in my code?

jlrdw's avatar

Also why not just paginate $faxStatusData?

Snapey's avatar

You cannot convert the data to an array and then expect pagination links to survive

$this->faxStatus = $faxStatusData->orderByDesc('id')->paginate(5)->toArray();

Why convert to an array?

webrobert's avatar

Because he got a PublicPropertyTypeNotAllowedException for trying to set the paginate to a public Livewire variable.

@rjrocks do this...


//	public $faxStatus = []; remove this

public function faxData()
{
    $faxStatusData = FaxOutgoing::where('sent_status', $this->status)
        ->whereNull('archive_by');

    // .... all your other code here. that's a different discussion.

    return $faxStatusData->orderByDesc('id')->paginate(5);

    // count fax
    //
    // remove all this if it's the same as the query above.

}

public function render()
{
	$faxdataPaginate = $this->faxData();

    return view('livewire.fax-queue-status',[
        'faxStatus' => $faxdataPaginate,
        'faxCount'  => $faxdataPaginate->total(), // here is the total of all the records from paginate
        ]);
}

Now you're going to have to fix your view...

Please or to participate in this conversation.