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 = [
|
$rules = [
|
||||||
'name' => 'required|string|max:255',
|
'name' => 'required|string|max:255',
|
||||||
'nik' => 'nullable|string|max:6|unique:users,nik',
|
|
||||||
'branch_id' => 'nullable|exists:branches,id',
|
'branch_id' => 'nullable|exists:branches,id',
|
||||||
'profile_photo_path' => 'nullable|image|mimes:jpeg,png,jpg|max:2048',
|
'profile_photo_path' => 'nullable|image|mimes:jpeg,png,jpg|max:2048',
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($this->password || $this->method() === 'POST') {
|
if ($this->password) {
|
||||||
$rules['email'] = 'required|email|unique:users,email';
|
|
||||||
$rules['password'] = 'required|string|min:8|confirmed';
|
$rules['password'] = 'required|string|min:8|confirmed';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->method() === 'PUT') {
|
if ($this->method() === 'PUT') {
|
||||||
$rules['email'] = 'required|email|unique:users,email,' . $this->id;
|
$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;
|
return $rules;
|
||||||
@ -41,9 +43,11 @@
|
|||||||
|
|
||||||
public function passedValidation()
|
public function passedValidation()
|
||||||
{
|
{
|
||||||
$this->merge([
|
if ($this->password!=='') {
|
||||||
'password' => Hash::make($this->password),
|
$this->merge([
|
||||||
]);
|
'password' => Hash::make($this->password),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ return new class extends Migration
|
|||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->string('email')->unique();
|
$table->string('email')->unique();
|
||||||
$table->timestamp('email_verified_at')->nullable();
|
$table->timestamp('email_verified_at')->nullable();
|
||||||
$table->string('password');
|
$table->string('password')->nullable();
|
||||||
$table->rememberToken();
|
$table->rememberToken();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
@ -159,7 +159,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="switch switch-sm">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
Loading…
Reference in New Issue
Block a user