jantinnerezo / livewire-alert

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

Load trait by default #106

Closed garbinmarcelo closed 1 year ago

garbinmarcelo commented 1 year ago

Hello, my question would be to check the possibility of loading this package by default in all components without the need to import and use in each component.

Would it be possible? If yes, how could you do it?

Thank you for your attention and for this package, it is very practical and useful.

MDylan commented 1 year ago

Just create a livewire component like: php artisan make:livewire BaseComponent

After it, place all needed trait and components in it, what you want to use example:

namespace App\Http\Livewire;

use Livewire\Component;
use Jantinnerezo\LivewireAlert\LivewireAlert;

class BaseComponent extends Component
{
    use LivewireAlert;

}

And after you create any other livewire class, just modify the used extended class like:

use App\Http\Livewire\BaseComponent;

class ListUsers extends BaseComponent
{
...
}