Display and update user preferences with livewire
The packages uses bootstrap 4 by default. In next release I will enable publishing views to your project directory so you can update them.
composer require akhaled/livewire-account-preferences
Very simple!
...
Akhaled\LivewireAccountPreferences\ServiceProvider::class
...
edit.blade.php
...
@livewire('account-preferences-edit', [
'account' => auth()->user()
'view' => 'account.edit' // optional, overrides global config property
])
...
show.blade.php
...
@livewire('account-preferences-show', [
'account' => auth()->user()
'view' => 'account.show' // optional, overrides global config property
])
...
3. Include livewire-sweetalert scripts along with @livewireScripts
If you want to enable sweetalert2 toast.
...
@livewireScripts
@livewireSweetalertScripts
...
Publish the configs: php artisan vendor:publish --tag=livewire-account-preferences
.
By default, package assume model has name
, email
and password
fields. If Model
class has defined $rules
property it overrides default. Please don't make the password
column required as changing password is done in separate stage.
Also, you need to define another property to tell component about filed usage.
Example :
class User
{
...
public $rules = [
'first_name' => 'required|string|min:6',
'last_name' => 'required|string|min:6',
'email_address' => 'required|email|max:500',
...
];
public $lwap = [
'first_name' => 'name',
'last_name' => 'name',
'email_address' => 'email'
]
...
}
views
:edit
: Global edit view resource location. If you submit a view with component it overrides the global config.show
: Global show view resource location. If you submit a view with component it overrides the global config.
routes
:edit
: Edit route name. Default is/account
show
: Show route name. Default is/account/edit
- Publish blade views
- Tailwind views