akhaled / livewire-account-preferences
Edit account model using livewire
Requires
- akhaled/livewire-sweetalert: ^0.1.0
- illuminate/support: ^6.0|^7.0|^8.0
- livewire/livewire: ^2.0
Requires (Dev)
- orchestra/testbench: ^6.18
- pestphp/pest: ^0.3.12
- pestphp/pest-plugin-faker: ^0.3.1
- phpunit/phpunit: ^9.3.3
This package is auto-updated.
Last update: 2024-12-16 22:18:27 UTC
README
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.
Installation
composer require akhaled/livewire-account-preferences
How to use
Very simple!
1. Add ServiceProvider
in config/app.php
... Akhaled\LivewireAccountPreferences\ServiceProvider::class ...
2. Add livewire component markup in your code
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 ...
4. Extra config file
Publish the configs: php artisan vendor:publish --tag=livewire-account-preferences
.
Define model fields
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' ] ... }
Available configuration
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
Todo
- Publish blade views
- Tailwind views