in my laravel livewire component, i have this code.
private $wireAlertService;
public function mount() {
$this->supervisors = User::getSupervisors();
$this->wireAlertService = new LivewireAlertService();
// dd($this->wireAlertService);
}
the commented out dd() dumps the instance of LivewireAlertService as wanted.
however, in other method, that fire's on button's wire:click, the variable $wireAlertService is null.
public function approveMany($attrs) {
// code
dd($this->wireAlertService, (new LivewireAlertService()));
// $this->wireAlertService->success($this);
// (new LivewireAlertService())->success($this);
}
in method approveMany() dd() dumps this
null
App\Services\LivewireAlertService {#2760}
therefore $this->wireAlertService->success($this); does not work (the desired one)
while (new LivewireAlertService())->success($this); works, but i don't like it as much.