add button revoke role user
This commit is contained in:
parent
f06edb4036
commit
c7975d513e
|
@ -122,4 +122,14 @@ public function userroles_assign(Request $request){
|
|||
return redirect()->route('users-roles.index')->with('success','Sukses Memberi Role User');
|
||||
}
|
||||
|
||||
public function userroles_deassign(Request $request){
|
||||
$listUser = $request->input('checkboxes', []);
|
||||
$listUser = $request->input('checkboxes', []);
|
||||
foreach($listUser as $listUsers) {
|
||||
$user = User::find($listUsers);
|
||||
$user->removeRole($request->roles_user);
|
||||
}
|
||||
return redirect()->route('users-roles.index')->with('success','Sukses Memberi Role User');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -80,7 +80,9 @@
|
|||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $datas->name }}</td>
|
||||
<td class="text-center"><button class="btn btn-success" data-toggle="modal" data-target="#modal{{ $loop->iteration }}">Edit</button> | <button class="btn btn-primary" data-toggle="modal" data-target="#assign{{ $loop->iteration }}">Assign Roles</button>
|
||||
<td class="text-center"><button class="btn btn-success" data-toggle="modal" data-target="#modal{{ $loop->iteration }}">Edit</button> |
|
||||
<button class="btn btn-primary" data-toggle="modal" data-target="#assign{{ $loop->iteration }}">Assign Roles</button> |
|
||||
<button class="btn btn-danger" data-toggle="modal" data-target="#deassign{{ $loop->iteration }}">Deassign Roles</button>
|
||||
</tr>
|
||||
<div class="modal fade" id="modal{{ $loop->iteration }}">
|
||||
<div class="modal-dialog">
|
||||
|
@ -145,7 +147,48 @@
|
|||
</div>
|
||||
<div class="modal-footer justify-content-between">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
<button type="submit" class="btn btn-primary">Tambah</button>
|
||||
<button type="submit" class="btn btn-primary">Tambah Role</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal-dialog -->
|
||||
</div>
|
||||
<div class="modal fade" id="deassign{{ $loop->iteration }}">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">DeAssign <b>{{ $datas->name }}</b> Ke:</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<form action="{{ route('users-roles.deassign')}}" method="post">
|
||||
@csrf
|
||||
<input type="hidden" name="roles_user" value="{{ $datas->name }}">
|
||||
<label class="col-form-label">User: </label>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" id="checkAll">
|
||||
<label for="checkAll" class="form-check-label">Check All</label>
|
||||
</div>
|
||||
@foreach ($user as $users)
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="itemCheckbox form-check-input" name="checkboxes[]" value="{{$users->id}}">
|
||||
<label for="{{$users->id}}" class="form-check-label">{{ $users->nama_gelar }}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer justify-content-between">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
<button type="submit" class="btn btn-danger">Hapus Role</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -97,6 +97,7 @@
|
|||
Route::get('/users-roles', [UserController::class, 'userroles_index'])->name('users-roles.index');
|
||||
Route::POST('/users-roles', [UserController::class, 'userroles_store'])->name('users-roles.store');
|
||||
Route::POST('/users-roles/assign', [UserController::class, 'userroles_assign'])->name('users-roles.assign');
|
||||
Route::POST('/users-roles/deassign', [UserController::class, 'userroles_deassign'])->name('users-roles.deassign');
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user