I use Laravel 11 and my component work perfectly in local, but I have error in production
component class:
<?php
namespace AppViewComponentsdashboardcafe;
use Closure;
use IlluminateContractsViewView;
use IlluminateViewComponent;
class VerifyButtons extends Component
{
public string $acceptIcon;
public string $rejectIcon;
public function __construct(public $status, public string $propertyName)
{
$this->acceptIcon = asset('assets/images/default-accept.svg');
$this->rejectIcon = asset('assets/images/default-reject.svg');
if ($this->status)
$this->acceptIcon = asset('assets/images/accept.svg');
if ($this->status === 0)
$this->rejectIcon = asset('assets/images/reject.svg');
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.dashboard.cafe.verify-buttons');
}
}
and in blade:
<div class="flex gap-3">
<img class="w-[28px] cursor-pointer" wire:click="$set('{{$propertyName}}',1)"
src="{{$acceptIcon}}"/>
<img class="w-[28px] cursor-pointer" wire:click="$set('{{$propertyName}}',0)"
src="{{$rejectIcon}}"/>
</div>
Php verison in local and production is 8.3.14
error:
Undefined variable $acceptIcon