79462923

Date: 2025-02-24 09:04:20
Score: 0.5
Natty:
Report link

Use Chirp::with('user')->paginate(10) directly in the Blade template without storing it in state.

Modify your Volt component to this:

 <?php 

use App\Models\Chirp; use Livewire\WithPagination;

$chirps = Chirp::with('user')->latest()->paginate(10); ?>

Modify the Blade View

<div>
<div class="mt-6 bg-white shadow-sm rounded-lg divide-y">
    @foreach ($chirps as $chirp)
        <div class="p-6 flex space-x-2" wire:key="{{ $chirp->id }}">
            ...
        </div>
    @endforeach
</div>

{{ $chirps->links() }}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Anh Ta Duc