Search code examples
phplaravellaravel-livewire

Laravel Livewire pass multiple parameters from view


I currently have a livewire component called live-data that I am passing a parameter orderNumber into as such:

@livewire('live-data',['orderNumber' => $order['order_number']])

Then in liveData.php I have:

public $orderNumber;

I would like to pass an additional parameter from the view to the livewire component named hasComponent. I have tried the following:

@livewire('live-data',['orderNumber' => $order['order_number']],['hasComponent'=>$hasComponent])

and in liveData.php

public $hasComponent;

However this is not working as the variable is not being assigned the value from the view. How is it possible to achieve this. Any help is greatly appreciated.


Solution

  • It should be like this

    @livewire('live-data',[
             'orderNumber'  => $order['order_number'],
             'hasComponent' =>  $hasComponent
             ])
    

    For more : https://laravel-livewire.com/docs/2.x/rendering-components