Update Module Users
- Fix Form Validation for Check Password, if null password not changed - Update Validation NIK on Update user data - Fix Role Not Assign if value is id not role name - Change User Migration, change password field to nullable
This commit is contained in:
parent
18b8ed5344
commit
47f248c7b3
@ -22,18 +22,20 @@
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|string|max:255',
|
||||
'nik' => 'nullable|string|max:6|unique:users,nik',
|
||||
'branch_id' => 'nullable|exists:branches,id',
|
||||
'profile_photo_path' => 'nullable|image|mimes:jpeg,png,jpg|max:2048',
|
||||
];
|
||||
|
||||
if ($this->password || $this->method() === 'POST') {
|
||||
$rules['email'] = 'required|email|unique:users,email';
|
||||
if ($this->password) {
|
||||
$rules['password'] = 'required|string|min:8|confirmed';
|
||||
}
|
||||
|
||||
if ($this->method() === 'PUT') {
|
||||
$rules['email'] = 'required|email|unique:users,email,' . $this->id;
|
||||
$rules['nik'] = 'nullable|string|max:6|unique:users,nik,' . $this->id;
|
||||
} else {
|
||||
$rules['email'] = 'required|email|unique:users,email';
|
||||
$rules['nik'] = 'nullable|string|max:6|unique:users,nik';
|
||||
}
|
||||
|
||||
return $rules;
|
||||
@ -41,11 +43,13 @@
|
||||
|
||||
public function passedValidation()
|
||||
{
|
||||
if ($this->password!=='') {
|
||||
$this->merge([
|
||||
'password' => Hash::make($this->password),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@ return new class extends Migration
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->string('password')->nullable();
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
@ -159,7 +159,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="switch switch-sm">
|
||||
<input {{ in_array($role->name,Auth()->user()->roles->pluck('name')->toArray()) ? 'checked' : '' }} name="roles" type="radio" value="{{ $role->id }}">
|
||||
<input {{ in_array($role->name,Auth()->user()->roles->pluck('name')->toArray()) ? 'checked' : '' }} name="roles" type="radio" value="{{ $role->name }}">
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
Loading…
Reference in New Issue
Block a user