feat: tambah role 'other' untuk guest user
- PermissionController: tambah 'other' ke daftar role - UserController validasi: in:admin,bk,wali_kelas,staff,other - User model: helper isOther() - Users view: filter dropdown + modal tambah user + label - Role 'other' bisa diatur hak aksesnya di menu Hak Akses Role
This commit is contained in:
@@ -19,7 +19,7 @@ class PermissionController extends Controller
|
|||||||
->get()
|
->get()
|
||||||
->groupBy('group');
|
->groupBy('group');
|
||||||
|
|
||||||
$roles = ['admin', 'bk', 'wali_kelas', 'staff'];
|
$roles = ['admin', 'bk', 'wali_kelas', 'staff', 'other'];
|
||||||
|
|
||||||
$rolePermissions = [];
|
$rolePermissions = [];
|
||||||
foreach ($roles as $role) {
|
foreach ($roles as $role) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class UserController extends Controller
|
|||||||
'username' => ['required', 'string', 'max:255', 'unique:users,username'],
|
'username' => ['required', 'string', 'max:255', 'unique:users,username'],
|
||||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email'],
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email'],
|
||||||
'password' => ['required', 'string', 'min:6'],
|
'password' => ['required', 'string', 'min:6'],
|
||||||
'role' => ['required', 'in:admin,bk,wali_kelas,staff'],
|
'role' => ['required', 'in:admin,bk,wali_kelas,staff,other'],
|
||||||
'is_active' => ['boolean'],
|
'is_active' => ['boolean'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ class UserController extends Controller
|
|||||||
'username' => ['required', 'string', 'max:255', 'unique:users,username,' . $user->id],
|
'username' => ['required', 'string', 'max:255', 'unique:users,username,' . $user->id],
|
||||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email,' . $user->id],
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email,' . $user->id],
|
||||||
'password' => ['nullable', 'string', 'min:6'],
|
'password' => ['nullable', 'string', 'min:6'],
|
||||||
'role' => ['required', 'in:admin,bk,wali_kelas,staff'],
|
'role' => ['required', 'in:admin,bk,wali_kelas,staff,other'],
|
||||||
'is_active' => ['boolean'],
|
'is_active' => ['boolean'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ class User extends Authenticatable
|
|||||||
public function isBK(): bool { return $this->role === 'bk'; }
|
public function isBK(): bool { return $this->role === 'bk'; }
|
||||||
public function isWaliKelas(): bool { return $this->role === 'wali_kelas'; }
|
public function isWaliKelas(): bool { return $this->role === 'wali_kelas'; }
|
||||||
public function isStaff(): bool { return $this->role === 'staff'; }
|
public function isStaff(): bool { return $this->role === 'staff'; }
|
||||||
|
public function isOther(): bool { return $this->role === 'other'; }
|
||||||
|
public function isStaff(): bool { return $this->role === 'staff'; }
|
||||||
|
|
||||||
public function canPermission(string $permission): bool
|
public function canPermission(string $permission): bool
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
<option value="bk" @selected(request('role') == 'bk')>BK</option>
|
<option value="bk" @selected(request('role') == 'bk')>BK</option>
|
||||||
<option value="wali_kelas" @selected(request('role') == 'wali_kelas')>Wali Kelas</option>
|
<option value="wali_kelas" @selected(request('role') == 'wali_kelas')>Wali Kelas</option>
|
||||||
<option value="staff" @selected(request('role') == 'staff')>Staff</option>
|
<option value="staff" @selected(request('role') == 'staff')>Staff</option>
|
||||||
|
<option value="other" @selected(request('role') == 'other')>Other</option>
|
||||||
</select>
|
</select>
|
||||||
<div class="flex space-x-2">
|
<div class="flex space-x-2">
|
||||||
<button type="submit" class="flex-1 px-4 py-2.5 text-sm font-medium text-white bg-blue-600 rounded-xl hover:bg-blue-700 transition">
|
<button type="submit" class="flex-1 px-4 py-2.5 text-sm font-medium text-white bg-blue-600 rounded-xl hover:bg-blue-700 transition">
|
||||||
@@ -209,6 +210,7 @@
|
|||||||
<option value="admin">Admin — Full akses</option>
|
<option value="admin">Admin — Full akses</option>
|
||||||
<option value="wali_kelas">Wali Kelas — Lihat kelas sendiri</option>
|
<option value="wali_kelas">Wali Kelas — Lihat kelas sendiri</option>
|
||||||
<option value="staff">Staff — Terbatas</option>
|
<option value="staff">Staff — Terbatas</option>
|
||||||
|
<option value="other">Other — Guest / Terbatas</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user