Hi -- been bashing my head on this all afternoon. Finally caved in and writing it up here so hopefully the hive mind can tell me what I'm doing stupid. It's pretty simple I think, but I'm new-ish to Laravel and basically green with Livewire so go easy :) Here goes...
I have a table of items and each item has a group field. Items belong in groups. I aiming for a page that displays all the items in a given group. The whole process is started with a call to a page /showItems/{group}. That route (in web.php) calls a class on a controller. The controller class catches the group with public function showItems (Request $request, Group $group) and then also passes it out of the return view ('showItems',['group',$group']) and into the blade showItems.blade.php. I can see the correct value makes it's way to showItems.blade.php since I can {{$group}} it. The next line calls the livewire component and I want to pass this $group variable into that component.
It looks like this: @livewire ('show-items',['group'=>$group])
In the render() function of the livewire component class, I want to do a database search based on $group. For instance **$items=Items::where('group_id',$group')->get(); and then pass $items into the livewire blade component.
Every which way I try this, I end up with Unable to resolve dependency [Parameter #0 [ $group ]] in class App\Livewire\Items.
I've tried declaring it public, not public, declaring it in render ($group).. nothing works. It's doing my head in. I've googled it, everything I can see other folk getting the same error but the solution if listed doesn't seem to fit my use case. I just want to pass an arbitrary value into a livewire class. What am I doing wrong?
If I hardcode the $group=4; in the livewire render() class and remove other references, the logic works as I'd expect, but that's not what I want!
cheers!
e