Using $this when not in object context while using pagination in livewire

266 Views Asked by At

.....\resources\views/vendor/livewire/tailwind.blade.php:3

3 @php(isset($this->numberOfPaginatorsRendered[$paginator->getPageName()]) ? $this->numberOfPaginatorsRendered[$paginator->getPageName()]++ : $this->numberOfPaginatorsRendered[$paginator->getPageName()] = 1)

shows above when i'm working with pagination in livewire in laravel

i had this in laravel class component

<?php namespace App\Http\Livewire;

use App\Models\HostelBookings; use App\Models\RecentActivity; use Livewire\Component; use Livewire\WithPagination;

class AdminDashboardActivity extends Component { use WithPagination;

public function render()
{
    $bookinglists = HostelBookings::latest()->paginate(5, ['*'], 'booking_page');
    $recentactivity = RecentActivity::latest()->paginate(8, ['*'], 'recent_page');

    return view('livewire.admin-dashboard-activity', ['bookinglists' => $bookinglists, 'recentactivity' => $recentactivity]);
}

}

and i had this in view component

{{-- Close your eyes. Count to one. That is how long forever feels. --}}

`        @foreach ($recentactivity as $activity)
            <div class="activity-body">
                <div class="activity-item">
                    <div class="activity-icon">
                        <i class="fas fa-circle"></i>
                    </div>
                    <div class="activity-info">
                        <span class="activity-text">{{ $activity->activity }} </span>
                        <br>
                        <span class="date">{{ $activity->created_at->diffForHumans() }}</span>
                    </div>
                </div>
            </div>
        @endforeach

<div class="pagination">
    {{ $recentactivity->links() }}
</div>

when i comment " use WithPagination;" code works fine but page got refreshed when i try to paginate i don't want the page to refreshed when i try to paginate

0

There are 0 best solutions below