jantinnerezo / livewire-alert

SweetAlert2 wrapper for Livewire
https://livewire-alert.jantinnerezo.com
MIT License
682 stars 73 forks source link

Dependency Injection Issue #142

Open aivisionbot opened 6 months ago

aivisionbot commented 6 months ago

hello , i use livewire 3 and livewire-alert": "^3.0.1

i use this code in my component :

       public function connect(Bot $bot)
          {
              $this->alert('question', '', [
                  'position' => 'center',
                  'timer' => false,
                  'toast' => false,
                  'text' => 'Have you connected your account with Pamm Link ? Enter Pamm Code : ',
                  'timerProgressBar' => true,
                  'showConfirmButton' => true,
                  'input' => 'number',
                  'confirmButtonText' => 'Submit',
                  'onConfirmed' => 'confirmedConnectBot' ,
                  'inputAttributes' => [
                      'bot' => $bot->id ,
                  ],
                  'showCancelButton' => true,
                  'cancelButtonText' => 'Cancel',
              ]);
          }

           #[On('confirmedConnectBot')]
          public function confirmedConnectBot($response)
          {

              $bot = $response['data']['inputAttributes']['bot'];

              $pamm_code = $response['value'] ;
           }

but i get this error : Unable to resolve dependency [Parameter #0 [ $response ]] in class App\Livewire\User\Bot\LastRequests

matticustard commented 2 months ago

I realize this issue is 4 months old but I had the same issue after upgrading to Livewire 3. It appears that the parameter must now be named $data instead of $response and the new parameter is the equivalent of the old $response['data'].

The new structure looks like this:

public function confirmedMethod($data)
{
    $value = $data['inputAttributes']['value'];

    // ...
}