Skip to content
This repository was archived by the owner on Mar 12, 2024. It is now read-only.

Commit 84f8bbd

Browse files
committed
extending the package
1 parent 5911843 commit 84f8bbd

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

README.md

+52
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,55 @@ Therefore you have to add this tag after the dashboard navigation div in navigat
7373
## Logging in
7474

7575
LLoadout inforce will default create a user with username of `[email protected]` and the password `password`
76+
77+
## Extending the package
78+
79+
Assume you want to add fields to the user view and want to save the field to the database. Than you can use the published view and extend the LLoadout user component.
80+
Herefore you have to create your own route to your own created component.
81+
82+
This is the route
83+
84+
```php
85+
Route::get('/user/detail/{user?}', \App\Http\Livewire\MyUser::class)->whereNumber('id')->name('users.edit');
86+
```
87+
88+
This can be your component
89+
```php
90+
<?php
91+
92+
namespace App\Http\Livewire;
93+
94+
use LLoadoutInforce\Http\Livewire\Traits\HandlesPermissions;
95+
use LLoadoutInforce\Http\Livewire\Traits\ShowPerks;
96+
97+
class MyUser extends \LLoadoutInforce\Http\Livewire\User
98+
{
99+
100+
101+
protected function rules()
102+
{
103+
104+
return [
105+
'user.name' => 'required|string',
106+
'user.email' => ['required', 'email', 'not_in:' . $this->user->id],
107+
'user.password' => 'required|confirmed',
108+
'user.password_confirmation' => 'required',
109+
'user.extrafield' => 'required'
110+
];
111+
}
112+
113+
public function saveUser()
114+
{
115+
$this->validate();
116+
117+
$this->handlePassword();
118+
$this->user->save();
119+
$this->user->syncRoles([$this->userRoles]);
120+
121+
}
122+
123+
124+
}
125+
126+
```
127+

0 commit comments

Comments
 (0)