Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jonatanflova's avatar

Using $this when not in object context

I just created a laravel project "^9.19" with jetstream and livewire "^2.5" but it created a simple component and got the following error. This is my current code:

patient.blade.php

@foreach ($patients as $patient)
    {{$patient->name}}
@endforeach

{{ $patients->links() }}

Patient.php

namespace App\Http\Livewire; use App\Models\User; use Livewire\Component; use Livewire\WithPagination;

class Patients extends Component { use WithPagination;

public function render()
{
    return view('livewire.patients'
    , [
        'patients' => User::paginate(10),
    ]
    );
}

}

0 likes
5 replies
vincent15000's avatar

What's the problem ?

I don't see anywhere in your code any $this but you mention it in the title.

2 likes
jonatanflova's avatar

I found the error, in the main controller I was sending to the view a model with pagination, and for some reason laravel confuses that pagination with the pagination in livewire. In conclusion, do not use 2 types of pagination in a single view, there should only be 1 type.

3 likes

Please or to participate in this conversation.