Skip to content
Advertisement

Undefined variable $services

I have this error. I did this a couple of times on a different pages with different subjects , but with the same method. It always worked. But for some reason now I’m getting this error.

Undefined variable $services (View:Cxampphtdocsaccountingresourcesviewslivewireservice-table.blade.php)

Possible type $services Did you mean $errors?

Web route

JavaScript

Model

JavaScript

My controller

JavaScript

Livewire table

JavaScript

And here is the view

JavaScript

Advertisement

Answer

You are sending data to the wrong view. You are sending data to service.index view but trying to get it in livewireservice-table so change the view like below then you can get it.

as the error explains it

Undefined variable $services (View:Cxampphtdocsaccountingresourcesviewslivewireservice-table.blade.php)

the problem is here return view('service.index', compact('services'))->with(request()->input('page'));

Try this

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement