Is it possible to pass more than 2 variables through the render method?

Please help

I’m struggling on passing data to my view, whenever I declare 2 variables everything works fine, but I’m trying to add a third one and it displays as undefined

public function render()
{
return view(‘livewire.mystore’, [‘part’ => Mypart::where(‘status’, ‘done’)->get()], [‘orders’ => Order::where(‘delivered’, false)->get()], [‘products’ => SoldProducts::latest()->take(50)->get()]);
}

Sorry if this is a dumb question, but I’ve searched about it with no success.

Hey @0bi-juan,

public function render()
{
    return view(‘livewire.mystore’, [
        ‘part’ => Mypart::where(‘status’, ‘done’)->get(),
        ‘orders’ => Order::where(‘delivered’, false)->get(),
        ‘products’ => SoldProducts::latest()->take(50)->get()
    ]);
} 

Try it like this. You pass multiple arrays to the view method, while you only have to pass one and assign key => value pairs as you wish :wink:

Yes ! that works, thanks!

You are really welcome!

1 Like