I have a component that I want to pass if button [true] then it shows. However it does not pass to the blade.
Component Usage
Default would be set as false in the component file, so I just pass whenever it sets as false [or to hide it]
<x-invoice.invoice-list :invoice="$item"></x-invoice.invoice-list>
Component File
class InvoiceList extends Component
{
public UserInvoice $invoice;
public $button;
/**
* Create a new component instance.
*/
public function __construct($invoice,$button = true)
{
$this->invoice = $invoice;
$this->button = $button;
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.invoice.invoice-list');
}
}
Component blade file
<div class="p-2 border border-gray-200 rounded-xl mb-3 text-center relative col-span-12 lg:col-span-6">
<div class="p-2 bg-black text-white rounded-xl font-bold text-xl mt-10">{{ format_currency($invoice->total) }}</div>
<div class="p-2 absolute top-0 right-0 me-2 capitalize">
<x-shared.listing-invoice-status-box :invoice="$invoice">{{ $invoice->status }}</x-shared.listing-invoice-status-box>
</div>
<div class="p-2 text-center font-bold">{{ __('Order List') }}</div>
<div class="p-2 border border-orange-100 rounded-xl bg-orange-50">
@foreach ($invoice->order as $order)
<x-shared.order-list :$order></x-shared.order-list>
@endforeach
</div>
@if ($button and $invoice->status=='pending')
<x-button.pay wire:click="$dispatch('openModal',{component:'modal.modal-invoice-do-payment',arguments:{'userInvoice':{{$invoice->id}}}})" class="mt-5 mb-2">{{__('Pay')}} <i
class="ps-2 fa-solid fa-circle-right"></i></x-button.pay>
@endif
</div>
Actually, it runs normally in localhost but whenever I deploy to server it causes
Undefined variable $button