feat: implement super admin role with spatie rbac and categorize sidebar by management
This commit is contained in:
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Employee;
|
||||||
|
use App\Models\SecurityGuard;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Vehicle;
|
||||||
|
use App\Models\VehicleActivity;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
|
||||||
|
class DashboardController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Tampilkan Dashboard Ringkasan Super Admin & RBAC.
|
||||||
|
*/
|
||||||
|
public function index(): View
|
||||||
|
{
|
||||||
|
$today = Carbon::today();
|
||||||
|
|
||||||
|
$metrics = [
|
||||||
|
'total_users' => User::count(),
|
||||||
|
'total_roles' => Role::count(),
|
||||||
|
'total_employees' => Employee::count(),
|
||||||
|
'total_vehicles' => Vehicle::count(),
|
||||||
|
'total_guards' => SecurityGuard::count(),
|
||||||
|
'activities_today' => VehicleActivity::whereDate('created_at', $today)->count(),
|
||||||
|
'activities_pending' => VehicleActivity::pending()->count(),
|
||||||
|
'activities_approved' => VehicleActivity::approved()->whereDate('created_at', $today)->count(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$usersByRole = User::with('roles')
|
||||||
|
->get()
|
||||||
|
->groupBy(function ($u) {
|
||||||
|
return $u->roles->first()?->name ?? $u->role ?? 'Tanpa Role';
|
||||||
|
})
|
||||||
|
->map->count();
|
||||||
|
|
||||||
|
$recentUsers = User::with(['roles', 'gate'])
|
||||||
|
->latest()
|
||||||
|
->take(6)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$recentActivities = VehicleActivity::with(['vehicle', 'driver', 'gate'])
|
||||||
|
->latest()
|
||||||
|
->take(5)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return view('admin.dashboard', compact('metrics', 'usersByRole', 'recentUsers', 'recentActivities'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
use Spatie\Permission\PermissionRegistrar;
|
||||||
|
|
||||||
|
class RolePermissionController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Tampilkan matriks Role & Permission RBAC.
|
||||||
|
*/
|
||||||
|
public function index(): View
|
||||||
|
{
|
||||||
|
$roles = Role::with('permissions')->orderBy('id')->get();
|
||||||
|
$modules = config('rbac_permissions.modules', []);
|
||||||
|
|
||||||
|
return view('admin.roles.index', compact('roles', 'modules'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Buat Role baru di sistem.
|
||||||
|
*/
|
||||||
|
public function storeRole(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'name' => ['required', 'string', 'max:50', 'unique:roles,name'],
|
||||||
|
], [
|
||||||
|
'name.required' => 'Nama role wajib diisi.',
|
||||||
|
'name.unique' => 'Role dengan nama tersebut sudah ada.',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$role = Role::create([
|
||||||
|
'name' => strtolower(trim(str_replace(' ', '_', $request->input('name')))),
|
||||||
|
'guard_name' => 'web',
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->route('admin.roles.index')
|
||||||
|
->with('success', "Role [{$role->name}] berhasil ditambahkan ke sistem.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perbarui hak akses (permissions) untuk suatu role dari matriks.
|
||||||
|
*/
|
||||||
|
public function updatePermissions(Request $request, int $roleId): RedirectResponse
|
||||||
|
{
|
||||||
|
$role = Role::findOrFail($roleId);
|
||||||
|
|
||||||
|
// Jangan izinkan modifikasi permission super_admin karena otomatis memiliki seluruh akses
|
||||||
|
if ($role->name === 'super_admin') {
|
||||||
|
return redirect()->route('admin.roles.index')
|
||||||
|
->with('error', 'Role Super Administrator selalu memiliki hak akses penuh (bypassed) dan tidak dapat dikurangi.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$selectedPermissions = $request->input('permissions', []);
|
||||||
|
$role->syncPermissions($selectedPermissions);
|
||||||
|
|
||||||
|
// Reset permission cache
|
||||||
|
app()[PermissionRegistrar::class]->forgetCachedPermissions();
|
||||||
|
|
||||||
|
return redirect()->route('admin.roles.index')
|
||||||
|
->with('success', "Matriks permission untuk role [{$role->name}] berhasil diperbarui.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hapus role kustom dari sistem.
|
||||||
|
*/
|
||||||
|
public function destroyRole(int $roleId): RedirectResponse
|
||||||
|
{
|
||||||
|
$role = Role::findOrFail($roleId);
|
||||||
|
|
||||||
|
// Proteksi role inti sistem
|
||||||
|
$coreRoles = ['super_admin', 'hse_admin', 'qma_admin', 'pg_admin', 'gate_officer'];
|
||||||
|
if (in_array($role->name, $coreRoles)) {
|
||||||
|
return redirect()->route('admin.roles.index')
|
||||||
|
->with('error', "Aksi Ditolak: Role inti sistem [{$role->name}] tidak dapat dihapus.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$name = $role->name;
|
||||||
|
$role->delete();
|
||||||
|
|
||||||
|
app()[PermissionRegistrar::class]->forgetCachedPermissions();
|
||||||
|
|
||||||
|
return redirect()->route('admin.roles.index')
|
||||||
|
->with('success', "Role [{$name}] berhasil dihapus dari sistem.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Gate;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
use Spatie\Permission\PermissionRegistrar;
|
||||||
|
|
||||||
|
class UserController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Tampilkan daftar seluruh pengguna sistem dengan filter & pencarian.
|
||||||
|
*/
|
||||||
|
public function index(Request $request): View
|
||||||
|
{
|
||||||
|
$query = User::with(['roles', 'gate'])->latest();
|
||||||
|
|
||||||
|
if ($request->filled('search')) {
|
||||||
|
$search = trim($request->input('search'));
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('name', 'like', "%{$search}%")
|
||||||
|
->orWhere('username', 'like', "%{$search}%")
|
||||||
|
->orWhere('email', 'like', "%{$search}%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->filled('role')) {
|
||||||
|
$roleFilter = $request->input('role');
|
||||||
|
$query->where(function ($q) use ($roleFilter) {
|
||||||
|
$q->whereHas('roles', fn ($rq) => $rq->where('name', $roleFilter))
|
||||||
|
->orWhere('role', $roleFilter);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$users = $query->with('permissions')->paginate(15)->withQueryString();
|
||||||
|
$roles = Role::orderBy('name')->get();
|
||||||
|
$gates = Gate::where('is_active', true)->orderBy('name')->get();
|
||||||
|
$modules = config('rbac_permissions.modules', []);
|
||||||
|
|
||||||
|
return view('admin.users.index', compact('users', 'roles', 'gates', 'modules'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simpan pengguna baru ke sistem beserta penugasan Spatie Role.
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'username' => ['required', 'string', 'max:50', 'unique:users,username'],
|
||||||
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email'],
|
||||||
|
'password' => ['required', 'string', 'min:6'],
|
||||||
|
'role' => ['required', 'string', 'exists:roles,name'],
|
||||||
|
'gate_id' => ['nullable', 'exists:gates,id'],
|
||||||
|
], [
|
||||||
|
'name.required' => 'Nama lengkap wajib diisi.',
|
||||||
|
'username.required' => 'Username wajib diisi.',
|
||||||
|
'username.unique' => 'Username tersebut sudah digunakan.',
|
||||||
|
'email.required' => 'Email wajib diisi.',
|
||||||
|
'email.unique' => 'Email tersebut sudah terdaftar.',
|
||||||
|
'password.required' => 'Password wajib diisi.',
|
||||||
|
'password.min' => 'Password minimal terdiri dari 6 karakter.',
|
||||||
|
'role.required' => 'Role wajib dipilih.',
|
||||||
|
'role.exists' => 'Role yang dipilih tidak valid.',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = User::create([
|
||||||
|
'name' => $validated['name'],
|
||||||
|
'username' => $validated['username'],
|
||||||
|
'email' => $validated['email'],
|
||||||
|
'password' => Hash::make($validated['password']),
|
||||||
|
'role' => $validated['role'], // Simpan ke kolom legacy untuk backwards-compat
|
||||||
|
'gate_id' => $validated['gate_id'] ?? null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assign Spatie Role
|
||||||
|
$user->assignRole($validated['role']);
|
||||||
|
|
||||||
|
// Sync Direct Permissions (jika ada izin khusus tambahan)
|
||||||
|
if ($request->has('direct_permissions')) {
|
||||||
|
$user->syncPermissions($request->input('direct_permissions', []));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset permission cache Spatie
|
||||||
|
app()[PermissionRegistrar::class]->forgetCachedPermissions();
|
||||||
|
|
||||||
|
return redirect()->route('admin.users.index')
|
||||||
|
->with('success', "Akun pengguna [{$user->name}] berhasil dibuat dengan role [{$validated['role']}].");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perbarui data pengguna & perbarui Role Spatie serta Direct Permissions.
|
||||||
|
*/
|
||||||
|
public function update(Request $request, int $id): RedirectResponse
|
||||||
|
{
|
||||||
|
$user = User::findOrFail($id);
|
||||||
|
|
||||||
|
$validated = $request->validate([
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'username' => ['required', 'string', 'max:50', Rule::unique('users', 'username')->ignore($user->id)],
|
||||||
|
'email' => ['required', 'string', 'email', 'max:255', Rule::unique('users', 'email')->ignore($user->id)],
|
||||||
|
'password' => ['nullable', 'string', 'min:6'],
|
||||||
|
'role' => ['required', 'string', 'exists:roles,name'],
|
||||||
|
'gate_id' => ['nullable', 'exists:gates,id'],
|
||||||
|
], [
|
||||||
|
'name.required' => 'Nama lengkap wajib diisi.',
|
||||||
|
'username.required' => 'Username wajib diisi.',
|
||||||
|
'username.unique' => 'Username tersebut sudah digunakan oleh akun lain.',
|
||||||
|
'email.required' => 'Email wajib diisi.',
|
||||||
|
'email.unique' => 'Email tersebut sudah digunakan oleh akun lain.',
|
||||||
|
'password.min' => 'Password minimal 6 karakter jika ingin diubah.',
|
||||||
|
'role.required' => 'Role wajib dipilih.',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user->name = $validated['name'];
|
||||||
|
$user->username = $validated['username'];
|
||||||
|
$user->email = $validated['email'];
|
||||||
|
$user->role = $validated['role'];
|
||||||
|
$user->gate_id = $validated['gate_id'] ?? null;
|
||||||
|
|
||||||
|
if (!empty($validated['password'])) {
|
||||||
|
$user->password = Hash::make($validated['password']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
// Sync Spatie Role
|
||||||
|
$user->syncRoles([$validated['role']]);
|
||||||
|
|
||||||
|
// Sync Direct Permissions
|
||||||
|
$user->syncPermissions($request->input('direct_permissions', []));
|
||||||
|
|
||||||
|
// Reset permission cache Spatie
|
||||||
|
app()[PermissionRegistrar::class]->forgetCachedPermissions();
|
||||||
|
|
||||||
|
return redirect()->route('admin.users.index')
|
||||||
|
->with('success', "Data pengguna [{$user->name}] berhasil diperbarui.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hapus akun pengguna dari sistem.
|
||||||
|
*/
|
||||||
|
public function destroy(int $id): RedirectResponse
|
||||||
|
{
|
||||||
|
$user = User::findOrFail($id);
|
||||||
|
|
||||||
|
// Proteksi: jangan hapus akun sendiri yang sedang login
|
||||||
|
if (Auth::id() === $user->id) {
|
||||||
|
return redirect()->route('admin.users.index')
|
||||||
|
->with('error', 'Aksi Ditolak: Anda tidak dapat menghapus akun Anda sendiri saat sedang login.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Proteksi: akun superadmin utama tidak boleh dihapus
|
||||||
|
if ($user->username === 'superadmin') {
|
||||||
|
return redirect()->route('admin.users.index')
|
||||||
|
->with('error', 'Aksi Ditolak: Akun Super Administrator utama sistem tidak dapat dihapus.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$name = $user->name;
|
||||||
|
$user->syncRoles([]);
|
||||||
|
$user->delete();
|
||||||
|
|
||||||
|
return redirect()->route('admin.users.index')
|
||||||
|
->with('success', "Akun pengguna [{$name}] berhasil dihapus dari sistem.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -71,6 +71,10 @@ class LoginController extends Controller
|
|||||||
*/
|
*/
|
||||||
private function redirectBasedOnRole($user): RedirectResponse
|
private function redirectBasedOnRole($user): RedirectResponse
|
||||||
{
|
{
|
||||||
|
if ($user->isSuperAdmin()) {
|
||||||
|
return redirect()->route('admin.dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
return match ($user->role) {
|
return match ($user->role) {
|
||||||
'hse_admin' => redirect()->route('hse.dashboard'),
|
'hse_admin' => redirect()->route('hse.dashboard'),
|
||||||
'qma_admin' => redirect()->route('qma.dashboard'),
|
'qma_admin' => redirect()->route('qma.dashboard'),
|
||||||
|
|||||||
@@ -19,10 +19,16 @@ class CheckRole
|
|||||||
return redirect()->route('login')->with('error', 'Silakan login terlebih dahulu untuk mengakses menu ini.');
|
return redirect()->route('login')->with('error', 'Silakan login terlebih dahulu untuk mengakses menu ini.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$userRole = $request->user()->role;
|
$user = $request->user();
|
||||||
|
$userRole = $user->role;
|
||||||
|
|
||||||
// Role 'admin' selalu memiliki hak akses penuh
|
// Role 'admin' dan 'super_admin' selalu memiliki hak akses penuh ke semua modul
|
||||||
if ($userRole === 'admin' || in_array($userRole, $roles)) {
|
if ($userRole === 'admin' || $userRole === 'super_admin' || $user->hasRole('super_admin') || $user->hasRole('admin')) {
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cek via kolom role string atau Spatie hasAnyRole
|
||||||
|
if (in_array($userRole, $roles) || $user->hasAnyRole($roles)) {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+27
-6
@@ -9,11 +9,27 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Spatie\Permission\Traits\HasRoles;
|
||||||
|
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
{
|
{
|
||||||
/** @use HasFactory<UserFactory> */
|
/** @use HasFactory<UserFactory> */
|
||||||
use HasFactory, Notifiable;
|
use HasFactory, Notifiable, HasRoles;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "booted" method of the model.
|
||||||
|
*/
|
||||||
|
protected static function booted(): void
|
||||||
|
{
|
||||||
|
static::created(function (User $user) {
|
||||||
|
if ($user->role && \Illuminate\Support\Facades\Schema::hasTable('roles')) {
|
||||||
|
$role = \Spatie\Permission\Models\Role::where('name', $user->role)->first();
|
||||||
|
if ($role && !$user->hasRole($user->role)) {
|
||||||
|
$user->assignRole($role);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
@@ -62,28 +78,33 @@ class User extends Authenticatable
|
|||||||
return $this->hasOne(SecurityGuard::class);
|
return $this->hasOne(SecurityGuard::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isSuperAdmin(): bool
|
||||||
|
{
|
||||||
|
return $this->role === 'super_admin' || $this->hasRole('super_admin');
|
||||||
|
}
|
||||||
|
|
||||||
public function isGateOfficer(): bool
|
public function isGateOfficer(): bool
|
||||||
{
|
{
|
||||||
return $this->role === 'gate_officer';
|
return $this->role === 'gate_officer' || $this->hasRole('gate_officer');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isHseAdmin(): bool
|
public function isHseAdmin(): bool
|
||||||
{
|
{
|
||||||
return $this->role === 'hse_admin';
|
return $this->isSuperAdmin() || $this->role === 'hse_admin' || $this->hasRole('hse_admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isQmaAdmin(): bool
|
public function isQmaAdmin(): bool
|
||||||
{
|
{
|
||||||
return $this->role === 'qma_admin';
|
return $this->isSuperAdmin() || $this->role === 'qma_admin' || $this->hasRole('qma_admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPgAdmin(): bool
|
public function isPgAdmin(): bool
|
||||||
{
|
{
|
||||||
return $this->role === 'pg_admin';
|
return $this->isSuperAdmin() || $this->role === 'pg_admin' || $this->hasRole('pg_admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isAdmin(): bool
|
public function isAdmin(): bool
|
||||||
{
|
{
|
||||||
return $this->role === 'admin';
|
return $this->isSuperAdmin() || $this->role === 'admin' || $this->hasRole('admin');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
@@ -21,5 +22,10 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
{
|
{
|
||||||
\Carbon\Carbon::setLocale('id');
|
\Carbon\Carbon::setLocale('id');
|
||||||
date_default_timezone_set(config('app.timezone', 'Asia/Jakarta'));
|
date_default_timezone_set(config('app.timezone', 'Asia/Jakarta'));
|
||||||
|
|
||||||
|
// Super Admin bypass: secara otomatis memiliki izin untuk semua ability
|
||||||
|
Gate::before(function ($user, $ability) {
|
||||||
|
return ($user->role === 'super_admin' || $user->hasRole('super_admin')) ? true : null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ return Application::configure(basePath: dirname(__DIR__))
|
|||||||
->withMiddleware(function (Middleware $middleware): void {
|
->withMiddleware(function (Middleware $middleware): void {
|
||||||
$middleware->alias([
|
$middleware->alias([
|
||||||
'role' => \App\Http\Middleware\CheckRole::class,
|
'role' => \App\Http\Middleware\CheckRole::class,
|
||||||
|
'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class,
|
||||||
|
'role_or_permission' => \Spatie\Permission\Middleware\RoleOrPermissionMiddleware::class,
|
||||||
]);
|
]);
|
||||||
})
|
})
|
||||||
->withExceptions(function (Exceptions $exceptions): void {
|
->withExceptions(function (Exceptions $exceptions): void {
|
||||||
|
|||||||
+2
-1
@@ -9,7 +9,8 @@
|
|||||||
"php": "^8.2",
|
"php": "^8.2",
|
||||||
"laravel/framework": "^12.0",
|
"laravel/framework": "^12.0",
|
||||||
"laravel/tinker": "^2.10.1",
|
"laravel/tinker": "^2.10.1",
|
||||||
"simplesoftwareio/simple-qrcode": "*"
|
"simplesoftwareio/simple-qrcode": "*",
|
||||||
|
"spatie/laravel-permission": "^8.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fakerphp/faker": "^1.23",
|
"fakerphp/faker": "^1.23",
|
||||||
|
|||||||
Generated
+150
-1
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "95d64c36b170378a8682c5138963ba09",
|
"content-hash": "170b1c005f6855019bb44940201e3dd9",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "bacon/bacon-qr-code",
|
"name": "bacon/bacon-qr-code",
|
||||||
@@ -3475,6 +3475,155 @@
|
|||||||
},
|
},
|
||||||
"time": "2021-02-08T20:43:55+00:00"
|
"time": "2021-02-08T20:43:55+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "spatie/laravel-package-tools",
|
||||||
|
"version": "1.93.3",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/spatie/laravel-package-tools.git",
|
||||||
|
"reference": "7aeef26bd8d4909bec744dbf47aee7d1395588c1"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/7aeef26bd8d4909bec744dbf47aee7d1395588c1",
|
||||||
|
"reference": "7aeef26bd8d4909bec744dbf47aee7d1395588c1",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"illuminate/contracts": "^10.0|^11.0|^12.0|^13.0",
|
||||||
|
"php": "^8.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"mockery/mockery": "^1.5",
|
||||||
|
"orchestra/testbench": "^8.0|^9.2|^10.0|^11.0",
|
||||||
|
"pestphp/pest": "^2.1|^3.1|^4.0",
|
||||||
|
"phpunit/php-code-coverage": "^10.0|^11.0|^12.0",
|
||||||
|
"phpunit/phpunit": "^10.5|^11.5|^12.5",
|
||||||
|
"spatie/pest-plugin-test-time": "^2.2|^3.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Spatie\\LaravelPackageTools\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Freek Van der Herten",
|
||||||
|
"email": "[email protected]",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Tools for creating Laravel packages",
|
||||||
|
"homepage": "https://github.com/spatie/laravel-package-tools",
|
||||||
|
"keywords": [
|
||||||
|
"laravel-package-tools",
|
||||||
|
"spatie"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/spatie/laravel-package-tools/issues",
|
||||||
|
"source": "https://github.com/spatie/laravel-package-tools/tree/1.93.3"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/spatie",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2026-09-28T07:16:50+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "spatie/laravel-permission",
|
||||||
|
"version": "8.3.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/spatie/laravel-permission.git",
|
||||||
|
"reference": "60e8ed5b2fbf043c2264433fc2680c76b8b66aa6"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/spatie/laravel-permission/zipball/60e8ed5b2fbf043c2264433fc2680c76b8b66aa6",
|
||||||
|
"reference": "60e8ed5b2fbf043c2264433fc2680c76b8b66aa6",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"illuminate/auth": "^12.0|^13.0",
|
||||||
|
"illuminate/container": "^12.0|^13.0",
|
||||||
|
"illuminate/contracts": "^12.0|^13.0",
|
||||||
|
"illuminate/database": "^12.0|^13.0",
|
||||||
|
"php": "^8.3",
|
||||||
|
"spatie/laravel-package-tools": "^1.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"larastan/larastan": "^3.9",
|
||||||
|
"laravel/octane": "^2.0",
|
||||||
|
"laravel/passport": "^13.0",
|
||||||
|
"laravel/pint": "^1.0",
|
||||||
|
"orchestra/testbench": "^10.0|^11.0",
|
||||||
|
"pestphp/pest": "^3.0|^4.0",
|
||||||
|
"pestphp/pest-plugin-laravel": "^3.0|^4.1",
|
||||||
|
"phpstan/phpstan": "^2.1"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"Spatie\\Permission\\PermissionServiceProvider"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-main": "8.x-dev",
|
||||||
|
"dev-master": "8.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"src/helpers.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Spatie\\Permission\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Freek Van der Herten",
|
||||||
|
"email": "[email protected]",
|
||||||
|
"homepage": "https://spatie.be",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Permission handling for Laravel 12 and up",
|
||||||
|
"homepage": "https://github.com/spatie/laravel-permission",
|
||||||
|
"keywords": [
|
||||||
|
"acl",
|
||||||
|
"laravel",
|
||||||
|
"permission",
|
||||||
|
"permissions",
|
||||||
|
"rbac",
|
||||||
|
"roles",
|
||||||
|
"security",
|
||||||
|
"spatie"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/spatie/laravel-permission/issues",
|
||||||
|
"source": "https://github.com/spatie/laravel-permission/tree/8.3.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/spatie",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2026-07-03T15:36:01+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/clock",
|
"name": "symfony/clock",
|
||||||
"version": "v7.4.8",
|
"version": "v7.4.8",
|
||||||
|
|||||||
@@ -0,0 +1,219 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Spatie\Permission\DefaultTeamResolver;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
'models' => [
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasPermissions" trait from this package, we need to know which
|
||||||
|
* Eloquent model should be used to retrieve your permissions. Of course, it
|
||||||
|
* is often just the "Permission" model but you may use whatever you like.
|
||||||
|
*
|
||||||
|
* The model you want to use as a Permission model needs to implement the
|
||||||
|
* `Spatie\Permission\Contracts\Permission` contract.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'permission' => Permission::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasRoles" trait from this package, we need to know which
|
||||||
|
* Eloquent model should be used to retrieve your roles. Of course, it
|
||||||
|
* is often just the "Role" model but you may use whatever you like.
|
||||||
|
*
|
||||||
|
* The model you want to use as a Role model needs to implement the
|
||||||
|
* `Spatie\Permission\Contracts\Role` contract.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'role' => Role::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "Teams" feature from this package, we need to know which
|
||||||
|
* Eloquent model should be used to retrieve your teams. Of course, it
|
||||||
|
* is often just the "Team" model but you may use whatever you like.
|
||||||
|
*/
|
||||||
|
'team' => null,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasModels" trait and passing raw IDs to syncModels,
|
||||||
|
* attachModels, or detachModels, this model class will be used to
|
||||||
|
* resolve those IDs. If null, defaults to the guard's model.
|
||||||
|
*/
|
||||||
|
'default_model' => null,
|
||||||
|
],
|
||||||
|
|
||||||
|
'table_names' => [
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasRoles" trait from this package, we need to know which
|
||||||
|
* table should be used to retrieve your roles. We have chosen a basic
|
||||||
|
* default value but you may easily change it to any table you like.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'roles' => 'roles',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasPermissions" trait from this package, we need to know which
|
||||||
|
* table should be used to retrieve your permissions. We have chosen a basic
|
||||||
|
* default value but you may easily change it to any table you like.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'permissions' => 'permissions',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasPermissions" trait from this package, we need to know which
|
||||||
|
* table should be used to retrieve your models permissions. We have chosen a
|
||||||
|
* basic default value but you may easily change it to any table you like.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'model_has_permissions' => 'model_has_permissions',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasRoles" trait from this package, we need to know which
|
||||||
|
* table should be used to retrieve your models roles. We have chosen a
|
||||||
|
* basic default value but you may easily change it to any table you like.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'model_has_roles' => 'model_has_roles',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasRoles" trait from this package, we need to know which
|
||||||
|
* table should be used to retrieve your roles permissions. We have chosen a
|
||||||
|
* basic default value but you may easily change it to any table you like.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'role_has_permissions' => 'role_has_permissions',
|
||||||
|
],
|
||||||
|
|
||||||
|
'column_names' => [
|
||||||
|
/*
|
||||||
|
* Change this if you want to name the related pivots other than defaults
|
||||||
|
*/
|
||||||
|
'role_pivot_key' => null, // default 'role_id',
|
||||||
|
'permission_pivot_key' => null, // default 'permission_id',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Change this if you want to name the related model primary key other than
|
||||||
|
* `model_id`.
|
||||||
|
*
|
||||||
|
* For example, this would be nice if your primary keys are all UUIDs. In
|
||||||
|
* that case, name this `model_uuid`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'model_morph_key' => 'model_id',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Change this if you want to use the teams feature and your related model's
|
||||||
|
* foreign key is other than `team_id`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'team_foreign_key' => 'team_id',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When set to true, the method for checking permissions will be registered on the gate.
|
||||||
|
* Set this to false if you want to implement custom logic for checking permissions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'register_permission_check_method' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When set to true, Laravel\Octane\Events\OperationTerminated event listener will be registered
|
||||||
|
* this will refresh permissions on every TickTerminated, TaskTerminated and RequestTerminated
|
||||||
|
* NOTE: This should not be needed in most cases, but an Octane/Vapor combination benefited from it.
|
||||||
|
*/
|
||||||
|
'register_octane_reset_listener' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Events will fire when a role or permission is assigned/unassigned:
|
||||||
|
* \Spatie\Permission\Events\RoleAttachedEvent
|
||||||
|
* \Spatie\Permission\Events\RoleDetachedEvent
|
||||||
|
* \Spatie\Permission\Events\PermissionAttachedEvent
|
||||||
|
* \Spatie\Permission\Events\PermissionDetachedEvent
|
||||||
|
*
|
||||||
|
* To enable, set to true, and then create listeners to watch these events.
|
||||||
|
*/
|
||||||
|
'events_enabled' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Teams Feature.
|
||||||
|
* When set to true the package implements teams using the 'team_foreign_key'.
|
||||||
|
* If you want the migrations to register the 'team_foreign_key', you must
|
||||||
|
* set this to true before doing the migration.
|
||||||
|
* If you already did the migration then you must make a new migration to also
|
||||||
|
* add 'team_foreign_key' to 'roles', 'model_has_roles', and 'model_has_permissions'
|
||||||
|
* (view the latest version of this package's migration file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
'teams' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The class to use to resolve the permissions team id
|
||||||
|
*/
|
||||||
|
'team_resolver' => DefaultTeamResolver::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Passport Client Credentials Grant
|
||||||
|
* When set to true the package will use Passports Client to check permissions
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use_passport_client_credentials' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When set to true, the required permission names are added to exception messages.
|
||||||
|
* This could be considered an information leak in some contexts, so the default
|
||||||
|
* setting is false here for optimum safety.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'display_permission_in_exception' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When set to true, the required role names are added to exception messages.
|
||||||
|
* This could be considered an information leak in some contexts, so the default
|
||||||
|
* setting is false here for optimum safety.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'display_role_in_exception' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* By default wildcard permission lookups are disabled.
|
||||||
|
* See documentation to understand supported syntax.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'enable_wildcard_permission' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The class to use for interpreting wildcard permissions.
|
||||||
|
* If you need to modify delimiters, override the class and specify its name here.
|
||||||
|
*/
|
||||||
|
// 'wildcard_permission' => Spatie\Permission\WildcardPermission::class,
|
||||||
|
|
||||||
|
/* Cache-specific settings */
|
||||||
|
|
||||||
|
'cache' => [
|
||||||
|
|
||||||
|
/*
|
||||||
|
* By default all permissions are cached for 24 hours to speed up performance.
|
||||||
|
* When permissions or roles are updated the cache is flushed automatically.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'expiration_time' => DateInterval::createFromDateString('24 hours'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The cache key used to store all permissions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'key' => 'spatie.permission.cache',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* You may optionally indicate a specific cache driver to use for permission and
|
||||||
|
* role caching using any of the `store` drivers listed in the cache.php config
|
||||||
|
* file. Using 'default' here means to use the `default` set in cache.php.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'store' => 'default',
|
||||||
|
],
|
||||||
|
];
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'modules' => [
|
||||||
|
'users' => [
|
||||||
|
'name' => 'Manajemen Pengguna (User Management)',
|
||||||
|
'icon' => 'fa-solid fa-users',
|
||||||
|
'permissions' => [
|
||||||
|
'users.view' => [
|
||||||
|
'label' => 'Melihat Daftar Pengguna',
|
||||||
|
'description' => 'Melihat daftar akun pengguna, rincian profil, dan status penempatan pos.',
|
||||||
|
],
|
||||||
|
'users.create' => [
|
||||||
|
'label' => 'Menambah Pengguna Baru',
|
||||||
|
'description' => 'Membuat akun pengguna baru dan menetapkan kredensial awal.',
|
||||||
|
],
|
||||||
|
'users.edit' => [
|
||||||
|
'label' => 'Mengubah Data Pengguna',
|
||||||
|
'description' => 'Mengubah nama, email, username, dan penempatan pos gerbang pengguna.',
|
||||||
|
],
|
||||||
|
'users.change_password' => [
|
||||||
|
'label' => 'Mengubah Password Pengguna',
|
||||||
|
'description' => 'Mereset atau memperbarui kata sandi pengguna dari panel admin.',
|
||||||
|
],
|
||||||
|
'users.assign_role' => [
|
||||||
|
'label' => 'Menetapkan Role Pengguna',
|
||||||
|
'description' => 'Menetapkan atau mengubah wewenang role Spatie kepada pengguna.',
|
||||||
|
],
|
||||||
|
'users.delete' => [
|
||||||
|
'label' => 'Menghapus Pengguna',
|
||||||
|
'description' => 'Menghapus akun pengguna dari sistem (dengan proteksi akun utama).',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'roles' => [
|
||||||
|
'name' => 'Manajemen Role & RBAC (Role & Permissions)',
|
||||||
|
'icon' => 'fa-solid fa-shield-halved',
|
||||||
|
'permissions' => [
|
||||||
|
'roles.view' => [
|
||||||
|
'label' => 'Melihat Matriks Role & Hak Akses',
|
||||||
|
'description' => 'Melihat daftar role dan pemetaan centang izin wewenang sistem.',
|
||||||
|
],
|
||||||
|
'roles.create' => [
|
||||||
|
'label' => 'Membuat Role Kustom Baru',
|
||||||
|
'description' => 'Menambahkan role tingkatan wewenang baru ke dalam sistem.',
|
||||||
|
],
|
||||||
|
'roles.edit_permissions' => [
|
||||||
|
'label' => 'Mengubah Hak Akses Role',
|
||||||
|
'description' => 'Memperbarui centang matriks izin/permissions untuk setiap role.',
|
||||||
|
],
|
||||||
|
'roles.delete' => [
|
||||||
|
'label' => 'Menghapus Role Kustom',
|
||||||
|
'description' => 'Menghapus role kustom yang sudah tidak digunakan (role inti terlindungi).',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'hse' => [
|
||||||
|
'name' => 'Modul HSE (Karyawan & SIMPER)',
|
||||||
|
'icon' => 'fa-solid fa-id-card',
|
||||||
|
'permissions' => [
|
||||||
|
'hse.employees.view' => [
|
||||||
|
'label' => 'Melihat Data Karyawan & SIMPER',
|
||||||
|
'description' => 'Melihat daftar master karyawan, status operator/driver, dan masa berlaku SIMPER.',
|
||||||
|
],
|
||||||
|
'hse.employees.create' => [
|
||||||
|
'label' => 'Menambah Data Karyawan / Driver',
|
||||||
|
'description' => 'Menambahkan karyawan baru ke master data HSE.',
|
||||||
|
],
|
||||||
|
'hse.employees.edit' => [
|
||||||
|
'label' => 'Mengubah Data Karyawan / SIMPER',
|
||||||
|
'description' => 'Memperbarui status driver, unit kerja, divisi, dan perpanjangan tanggal SIMPER.',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'qma' => [
|
||||||
|
'name' => 'Modul QMA (Kendaraan & Log Aktivitas)',
|
||||||
|
'icon' => 'fa-solid fa-car',
|
||||||
|
'permissions' => [
|
||||||
|
'qma.vehicles.view' => [
|
||||||
|
'label' => 'Melihat Master Kendaraan',
|
||||||
|
'description' => 'Melihat master data kendaraan ringan (LV) dan unit support.',
|
||||||
|
],
|
||||||
|
'qma.vehicles.create' => [
|
||||||
|
'label' => 'Menambah Unit Kendaraan',
|
||||||
|
'description' => 'Menambahkan unit kendaraan baru dan dokumen kendaraan.',
|
||||||
|
],
|
||||||
|
'qma.vehicles.edit' => [
|
||||||
|
'label' => 'Mengubah Data Kendaraan',
|
||||||
|
'description' => 'Memperbarui informasi status, HM/KM, dokumen STNK/KIR/SILO kendaraan.',
|
||||||
|
],
|
||||||
|
'qma.vehicles.delete' => [
|
||||||
|
'label' => 'Menghapus Data Kendaraan',
|
||||||
|
'description' => 'Menghapus unit kendaraan (terlindungi jika memiliki riwayat aktivitas).',
|
||||||
|
],
|
||||||
|
'qma.logs.view' => [
|
||||||
|
'label' => 'Melihat Log Aktivitas Kendaraan',
|
||||||
|
'description' => 'Melihat riwayat 10 kolom pergerakan kendaraan masuk/keluar proyek.',
|
||||||
|
],
|
||||||
|
'qma.summary.view' => [
|
||||||
|
'label' => 'Melihat Ringkasan Aktivitas & Statistik',
|
||||||
|
'description' => 'Melihat summary dan grafik agregat penggunaan kendaraan.',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'pg' => [
|
||||||
|
'name' => 'Modul Private Guard (Satpam & Verifikasi Gerbang)',
|
||||||
|
'icon' => 'fa-solid fa-user-shield',
|
||||||
|
'permissions' => [
|
||||||
|
'pg.guards.view' => [
|
||||||
|
'label' => 'Melihat Data Satpam',
|
||||||
|
'description' => 'Melihat daftar personil satpam, regu/tim jaga, dan penempatan pos gerbang.',
|
||||||
|
],
|
||||||
|
'pg.guards.create' => [
|
||||||
|
'label' => 'Menambah Personil Satpam Baru',
|
||||||
|
'description' => 'Mendaftarkan satpam baru dan otomatis membuatkan akun login lapangan.',
|
||||||
|
],
|
||||||
|
'pg.guards.edit' => [
|
||||||
|
'label' => 'Mengubah Data Satpam',
|
||||||
|
'description' => 'Mengubah regu, nama, nomor badge, dan pos penugasan satpam.',
|
||||||
|
],
|
||||||
|
'pg.guards.toggle' => [
|
||||||
|
'label' => 'Mengaktifkan / Menonaktifkan Satpam',
|
||||||
|
'description' => 'Mengubah status aktif personil satpam untuk bertugas di pos.',
|
||||||
|
],
|
||||||
|
'pg.guards.delete' => [
|
||||||
|
'label' => 'Menghapus Data Satpam',
|
||||||
|
'description' => 'Menghapus personil satpam dan akun login terkait.',
|
||||||
|
],
|
||||||
|
'pg.logs.view' => [
|
||||||
|
'label' => 'Melihat Log Verifikasi Pos Gerbang',
|
||||||
|
'description' => 'Melihat riwayat audit pemeriksaan yang telah disetujui / ditolak oleh satpam.',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'gate' => [
|
||||||
|
'name' => 'Pos Gerbang Lapangan (Gate Officer Verification)',
|
||||||
|
'icon' => 'fa-solid fa-shield-halved',
|
||||||
|
'permissions' => [
|
||||||
|
'gate.inspect' => [
|
||||||
|
'label' => 'Membuka Layar Antrean Pos Gerbang',
|
||||||
|
'description' => 'Melihat antrean live kendaraan yang masuk/keluar di pos gerbang.',
|
||||||
|
],
|
||||||
|
'gate.approve' => [
|
||||||
|
'label' => 'Menyetujui Verifikasi Kendaraan (Approve)',
|
||||||
|
'description' => 'Menyetujui perlintasan kendaraan dan memperbarui odometer master.',
|
||||||
|
],
|
||||||
|
'gate.reject' => [
|
||||||
|
'label' => 'Menolak Verifikasi Kendaraan (Reject)',
|
||||||
|
'description' => 'Menolak perlintasan kendaraan dengan memberikan catatan alasan.',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
@@ -26,6 +26,7 @@ class UserFactory extends Factory
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => fake()->name(),
|
'name' => fake()->name(),
|
||||||
|
'username' => fake()->unique()->userName(),
|
||||||
'email' => fake()->unique()->safeEmail(),
|
'email' => fake()->unique()->safeEmail(),
|
||||||
'email_verified_at' => now(),
|
'email_verified_at' => now(),
|
||||||
'password' => static::$password ??= Hash::make('password'),
|
'password' => static::$password ??= Hash::make('password'),
|
||||||
@@ -42,4 +43,19 @@ class UserFactory extends Factory
|
|||||||
'email_verified_at' => null,
|
'email_verified_at' => null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure the model factory.
|
||||||
|
*/
|
||||||
|
public function configure(): static
|
||||||
|
{
|
||||||
|
return $this->afterCreating(function (User $user) {
|
||||||
|
if ($user->role && \Illuminate\Support\Facades\Schema::hasTable('roles')) {
|
||||||
|
$role = \Spatie\Permission\Models\Role::where('name', $user->role)->first();
|
||||||
|
if ($role && !$user->hasRole($user->role)) {
|
||||||
|
$user->assignRole($role);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,137 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$teams = config('permission.teams');
|
||||||
|
$tableNames = config('permission.table_names');
|
||||||
|
$columnNames = config('permission.column_names');
|
||||||
|
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
|
||||||
|
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
|
||||||
|
|
||||||
|
throw_if(empty($tableNames), 'Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||||
|
throw_if($teams && empty($columnNames['team_foreign_key'] ?? null), 'Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered.
|
||||||
|
*/
|
||||||
|
Schema::create($tableNames['permissions'], static function (Blueprint $table) {
|
||||||
|
$table->id(); // permission id
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('guard_name');
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->unique(['name', 'guard_name']);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered.
|
||||||
|
*/
|
||||||
|
Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) {
|
||||||
|
$table->id(); // role id
|
||||||
|
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
|
||||||
|
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
|
||||||
|
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
|
||||||
|
}
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('guard_name');
|
||||||
|
$table->timestamps();
|
||||||
|
if ($teams || config('permission.testing')) {
|
||||||
|
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
||||||
|
} else {
|
||||||
|
$table->unique(['name', 'guard_name']);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
|
||||||
|
$table->unsignedBigInteger($pivotPermission);
|
||||||
|
|
||||||
|
$table->string('model_type');
|
||||||
|
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||||
|
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
|
||||||
|
|
||||||
|
$table->foreign($pivotPermission)
|
||||||
|
->references('id') // permission id
|
||||||
|
->on($tableNames['permissions'])
|
||||||
|
->cascadeOnDelete();
|
||||||
|
if ($teams) {
|
||||||
|
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||||
|
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
|
||||||
|
|
||||||
|
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||||
|
'model_has_permissions_permission_model_type_primary');
|
||||||
|
} else {
|
||||||
|
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||||
|
'model_has_permissions_permission_model_type_primary');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
|
||||||
|
$table->unsignedBigInteger($pivotRole);
|
||||||
|
|
||||||
|
$table->string('model_type');
|
||||||
|
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||||
|
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
|
||||||
|
|
||||||
|
$table->foreign($pivotRole)
|
||||||
|
->references('id') // role id
|
||||||
|
->on($tableNames['roles'])
|
||||||
|
->cascadeOnDelete();
|
||||||
|
if ($teams) {
|
||||||
|
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||||
|
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
|
||||||
|
|
||||||
|
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||||
|
'model_has_roles_role_model_type_primary');
|
||||||
|
} else {
|
||||||
|
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||||
|
'model_has_roles_role_model_type_primary');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
|
||||||
|
$table->unsignedBigInteger($pivotPermission);
|
||||||
|
$table->unsignedBigInteger($pivotRole);
|
||||||
|
|
||||||
|
$table->foreign($pivotPermission)
|
||||||
|
->references('id') // permission id
|
||||||
|
->on($tableNames['permissions'])
|
||||||
|
->cascadeOnDelete();
|
||||||
|
|
||||||
|
$table->foreign($pivotRole)
|
||||||
|
->references('id') // role id
|
||||||
|
->on($tableNames['roles'])
|
||||||
|
->cascadeOnDelete();
|
||||||
|
|
||||||
|
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
|
||||||
|
});
|
||||||
|
|
||||||
|
app('cache')
|
||||||
|
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||||
|
->forget(config('permission.cache.key'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
$tableNames = config('permission.table_names');
|
||||||
|
|
||||||
|
throw_if(empty($tableNames), 'Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||||
|
|
||||||
|
Schema::dropIfExists($tableNames['role_has_permissions']);
|
||||||
|
Schema::dropIfExists($tableNames['model_has_roles']);
|
||||||
|
Schema::dropIfExists($tableNames['model_has_permissions']);
|
||||||
|
Schema::dropIfExists($tableNames['roles']);
|
||||||
|
Schema::dropIfExists($tableNames['permissions']);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -267,5 +267,8 @@ class DatabaseSeeder extends Seeder
|
|||||||
'stnk_document' => 'STNK-BH-8412-AA',
|
'stnk_document' => 'STNK-BH-8412-AA',
|
||||||
'kir_document' => 'KIR-2026/11',
|
'kir_document' => 'KIR-2026/11',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// 6. Seed RBAC Roles, Permissions & Super Admin
|
||||||
|
$this->call(RolePermissionSeeder::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
use Spatie\Permission\PermissionRegistrar;
|
||||||
|
|
||||||
|
class RolePermissionSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
// 1. Reset cache permission Spatie
|
||||||
|
app()[PermissionRegistrar::class]->forgetCachedPermissions();
|
||||||
|
|
||||||
|
// 2. Baca seluruh daftar permission dari konfigurasi rbac_permissions
|
||||||
|
$modules = config('rbac_permissions.modules', []);
|
||||||
|
$allPermissions = [];
|
||||||
|
|
||||||
|
foreach ($modules as $moduleKey => $moduleData) {
|
||||||
|
foreach ($moduleData['permissions'] as $permKey => $permMeta) {
|
||||||
|
$allPermissions[] = $permKey;
|
||||||
|
Permission::firstOrCreate([
|
||||||
|
'name' => $permKey,
|
||||||
|
'guard_name' => 'web',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Pemetaan Default Permission per Role
|
||||||
|
$rolesWithPermissions = [
|
||||||
|
'super_admin' => $allPermissions,
|
||||||
|
'hse_admin' => [
|
||||||
|
'hse.employees.view',
|
||||||
|
'hse.employees.create',
|
||||||
|
'hse.employees.edit',
|
||||||
|
],
|
||||||
|
'qma_admin' => [
|
||||||
|
'qma.vehicles.view',
|
||||||
|
'qma.vehicles.create',
|
||||||
|
'qma.vehicles.edit',
|
||||||
|
'qma.vehicles.delete',
|
||||||
|
'qma.logs.view',
|
||||||
|
'qma.summary.view',
|
||||||
|
],
|
||||||
|
'pg_admin' => [
|
||||||
|
'pg.guards.view',
|
||||||
|
'pg.guards.create',
|
||||||
|
'pg.guards.edit',
|
||||||
|
'pg.guards.toggle',
|
||||||
|
'pg.guards.delete',
|
||||||
|
'pg.logs.view',
|
||||||
|
],
|
||||||
|
'gate_officer' => [
|
||||||
|
'gate.inspect',
|
||||||
|
'gate.approve',
|
||||||
|
'gate.reject',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($rolesWithPermissions as $roleName => $perms) {
|
||||||
|
$role = Role::firstOrCreate(['name' => $roleName, 'guard_name' => 'web']);
|
||||||
|
$role->syncPermissions($perms);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Buat Akun Default Super Admin
|
||||||
|
$superAdmin = User::firstOrCreate(
|
||||||
|
['username' => 'superadmin'],
|
||||||
|
[
|
||||||
|
'name' => 'Super Administrator',
|
||||||
|
'email' => '[email protected]',
|
||||||
|
'password' => Hash::make('password'),
|
||||||
|
'role' => 'super_admin',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!$superAdmin->hasRole('super_admin')) {
|
||||||
|
$superAdmin->assignRole('super_admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. Sinkronisasi Akun Existing ke Spatie Roles
|
||||||
|
$existingUsers = User::all();
|
||||||
|
foreach ($existingUsers as $user) {
|
||||||
|
if ($user->role && in_array($user->role, array_keys($rolesWithPermissions))) {
|
||||||
|
if (!$user->hasRole($user->role)) {
|
||||||
|
$user->assignRole($user->role);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+2497
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,278 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'Dashboard Super Admin - RKM KMH')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="space-y-6">
|
||||||
|
<!-- Header Halaman -->
|
||||||
|
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
|
||||||
|
<div>
|
||||||
|
<h1 class="text-2xl font-black text-slate-800 tracking-tight flex items-center gap-2.5">
|
||||||
|
<span class="w-2.5 h-7 rounded-full bg-indigo-600 inline-block"></span>
|
||||||
|
Dashboard Super Admin & RBAC
|
||||||
|
</h1>
|
||||||
|
<p class="text-xs text-slate-500 mt-1">
|
||||||
|
Pusat kendali arsitektur sistem, pengelolaan pengguna, dan matriks hak akses Role-Based Access Control (RBAC).
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-2.5">
|
||||||
|
<a href="{{ route('admin.users.index') }}"
|
||||||
|
class="inline-flex items-center gap-2 px-4 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-sm transition">
|
||||||
|
<i class="fa-solid fa-users-gear text-sm"></i>
|
||||||
|
<span>Kelola Pengguna</span>
|
||||||
|
</a>
|
||||||
|
<a href="{{ route('admin.roles.index') }}"
|
||||||
|
class="inline-flex items-center gap-2 px-4 py-2.5 bg-white border border-slate-200 hover:bg-slate-50 text-slate-700 rounded-xl text-xs font-bold shadow-sm transition">
|
||||||
|
<i class="fa-solid fa-shield-halved text-indigo-600 text-sm"></i>
|
||||||
|
<span>Matriks Role & Izin</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Alert Notifikasi Flash -->
|
||||||
|
@if(session('success'))
|
||||||
|
<div class="p-4 bg-emerald-50 border border-emerald-200 rounded-2xl flex items-center justify-between text-emerald-800 text-xs font-semibold">
|
||||||
|
<div class="flex items-center gap-2.5">
|
||||||
|
<i class="fa-solid fa-circle-check text-emerald-600 text-base"></i>
|
||||||
|
<span>{{ session('success') }}</span>
|
||||||
|
</div>
|
||||||
|
<button type="button" onclick="this.parentElement.remove()" class="text-emerald-500 hover:text-emerald-700">
|
||||||
|
<i class="fa-solid fa-xmark"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Kartu Metrik Utama -->
|
||||||
|
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||||
|
<!-- Total Pengguna -->
|
||||||
|
<div class="bg-white p-4 sm:p-5 rounded-2xl border border-slate-200/80 shadow-sm relative overflow-hidden group hover:border-indigo-300 transition">
|
||||||
|
<div class="flex items-center justify-between mb-2">
|
||||||
|
<span class="text-[11px] font-bold text-slate-400 uppercase tracking-wider">Total Akun</span>
|
||||||
|
<div class="w-8 h-8 rounded-xl bg-indigo-50 text-indigo-600 flex items-center justify-center text-sm">
|
||||||
|
<i class="fa-solid fa-users"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="text-2xl font-black text-slate-800">{{ $metrics['total_users'] }}</div>
|
||||||
|
<p class="text-[11px] text-slate-500 mt-1">Terdaftar dalam sistem</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Total Roles Spatie -->
|
||||||
|
<div class="bg-white p-4 sm:p-5 rounded-2xl border border-slate-200/80 shadow-sm relative overflow-hidden group hover:border-violet-300 transition">
|
||||||
|
<div class="flex items-center justify-between mb-2">
|
||||||
|
<span class="text-[11px] font-bold text-slate-400 uppercase tracking-wider">Total Role RBAC</span>
|
||||||
|
<div class="w-8 h-8 rounded-xl bg-violet-50 text-violet-600 flex items-center justify-center text-sm">
|
||||||
|
<i class="fa-solid fa-shield-halved"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="text-2xl font-black text-slate-800">{{ $metrics['total_roles'] }}</div>
|
||||||
|
<p class="text-[11px] text-slate-500 mt-1">Tingkatan wewenang</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Master Data Operasional (HSE & QMA) -->
|
||||||
|
<div class="bg-white p-4 sm:p-5 rounded-2xl border border-slate-200/80 shadow-sm relative overflow-hidden group hover:border-emerald-300 transition">
|
||||||
|
<div class="flex items-center justify-between mb-2">
|
||||||
|
<span class="text-[11px] font-bold text-slate-400 uppercase tracking-wider">Master Data</span>
|
||||||
|
<div class="w-8 h-8 rounded-xl bg-emerald-50 text-emerald-600 flex items-center justify-center text-sm">
|
||||||
|
<i class="fa-solid fa-database"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-baseline gap-2">
|
||||||
|
<span class="text-2xl font-black text-slate-800">{{ $metrics['total_vehicles'] }}</span>
|
||||||
|
<span class="text-xs text-slate-400 font-semibold">Unit</span>
|
||||||
|
<span class="text-slate-300">/</span>
|
||||||
|
<span class="text-lg font-black text-slate-700">{{ $metrics['total_employees'] }}</span>
|
||||||
|
<span class="text-xs text-slate-400 font-semibold">Karyawan</span>
|
||||||
|
</div>
|
||||||
|
<p class="text-[11px] text-slate-500 mt-1">Kendaraan & Simper</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Aktivitas Hari Ini -->
|
||||||
|
<div class="bg-white p-4 sm:p-5 rounded-2xl border border-slate-200/80 shadow-sm relative overflow-hidden group hover:border-amber-300 transition">
|
||||||
|
<div class="flex items-center justify-between mb-2">
|
||||||
|
<span class="text-[11px] font-bold text-slate-400 uppercase tracking-wider">Aktivitas Hari Ini</span>
|
||||||
|
<div class="w-8 h-8 rounded-xl bg-amber-50 text-amber-600 flex items-center justify-center text-sm">
|
||||||
|
<i class="fa-solid fa-clock-rotate-left"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-baseline gap-2">
|
||||||
|
<span class="text-2xl font-black text-slate-800">{{ $metrics['activities_today'] }}</span>
|
||||||
|
<span class="text-xs text-slate-400 font-semibold">Total</span>
|
||||||
|
@if($metrics['activities_pending'] > 0)
|
||||||
|
<span class="px-2 py-0.5 rounded-full text-[10px] font-black bg-amber-100 text-amber-700">
|
||||||
|
{{ $metrics['activities_pending'] }} antre
|
||||||
|
</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<p class="text-[11px] text-slate-500 mt-1">{{ $metrics['activities_approved'] }} sudah diverifikasi</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Shortcut Lintas Modul Sistem (Super Admin Quick Nav) -->
|
||||||
|
<div class="bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm">
|
||||||
|
<h2 class="text-sm font-bold text-slate-800 mb-3 flex items-center gap-2">
|
||||||
|
<i class="fa-solid fa-compass text-indigo-600"></i>
|
||||||
|
Akses Langsung ke Seluruh Modul Operasional (Super Admin Bypass)
|
||||||
|
</h2>
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3">
|
||||||
|
<!-- HSE Card -->
|
||||||
|
<a href="{{ route('hse.dashboard') }}" class="p-3.5 rounded-xl border border-slate-100 bg-slate-50/70 hover:bg-emerald-50/60 hover:border-emerald-200 transition group flex items-start gap-3">
|
||||||
|
<div class="w-9 h-9 rounded-lg bg-emerald-600 text-white flex items-center justify-center flex-shrink-0 group-hover:scale-105 transition">
|
||||||
|
<i class="fa-solid fa-id-card text-sm"></i>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3 class="text-xs font-bold text-slate-800 group-hover:text-emerald-800">Modul HSE</h3>
|
||||||
|
<p class="text-[11px] text-slate-500 mt-0.5">Kelola SIMPER & Data Karyawan</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<!-- QMA Card -->
|
||||||
|
<a href="{{ route('qma.dashboard') }}" class="p-3.5 rounded-xl border border-slate-100 bg-slate-50/70 hover:bg-blue-50/60 hover:border-blue-200 transition group flex items-start gap-3">
|
||||||
|
<div class="w-9 h-9 rounded-lg bg-blue-600 text-white flex items-center justify-center flex-shrink-0 group-hover:scale-105 transition">
|
||||||
|
<i class="fa-solid fa-car text-sm"></i>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3 class="text-xs font-bold text-slate-800 group-hover:text-blue-800">Modul QMA</h3>
|
||||||
|
<p class="text-[11px] text-slate-500 mt-0.5">Master Kendaraan & Log Aktivitas</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<!-- PG Card -->
|
||||||
|
<a href="{{ route('pg.dashboard') }}" class="p-3.5 rounded-xl border border-slate-100 bg-slate-50/70 hover:bg-purple-50/60 hover:border-purple-200 transition group flex items-start gap-3">
|
||||||
|
<div class="w-9 h-9 rounded-lg bg-purple-600 text-white flex items-center justify-center flex-shrink-0 group-hover:scale-105 transition">
|
||||||
|
<i class="fa-solid fa-user-shield text-sm"></i>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3 class="text-xs font-bold text-slate-800 group-hover:text-purple-800">Modul Private Guard</h3>
|
||||||
|
<p class="text-[11px] text-slate-500 mt-0.5">Data Satpam & Log Verifikasi</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<!-- Pos Gerbang -->
|
||||||
|
<a href="{{ route('pg.gate.inspection') }}" class="p-3.5 rounded-xl border border-slate-100 bg-slate-50/70 hover:bg-amber-50/60 hover:border-amber-200 transition group flex items-start gap-3">
|
||||||
|
<div class="w-9 h-9 rounded-lg bg-amber-600 text-white flex items-center justify-center flex-shrink-0 group-hover:scale-105 transition">
|
||||||
|
<i class="fa-solid fa-shield-halved text-sm"></i>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3 class="text-xs font-bold text-slate-800 group-hover:text-amber-800">Inspeksi Pos Gerbang</h3>
|
||||||
|
<p class="text-[11px] text-slate-500 mt-0.5">Layar Verifikasi Antrean Unit</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Grid Dua Kolom: Distribusi Role & Pengguna Terbaru -->
|
||||||
|
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||||
|
<!-- Distribusi Role Pengguna -->
|
||||||
|
<div class="bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm lg:col-span-1">
|
||||||
|
<h2 class="text-sm font-bold text-slate-800 mb-4 flex items-center justify-between">
|
||||||
|
<span>Distribusi Pengguna per Role</span>
|
||||||
|
<span class="text-[11px] font-semibold text-slate-400">{{ $metrics['total_users'] }} User</span>
|
||||||
|
</h2>
|
||||||
|
<div class="space-y-3">
|
||||||
|
@foreach($usersByRole as $roleName => $count)
|
||||||
|
@php
|
||||||
|
$percentage = $metrics['total_users'] > 0 ? round(($count / $metrics['total_users']) * 100) : 0;
|
||||||
|
$badgeColor = match($roleName) {
|
||||||
|
'super_admin' => 'bg-indigo-500',
|
||||||
|
'hse_admin' => 'bg-emerald-500',
|
||||||
|
'qma_admin' => 'bg-blue-500',
|
||||||
|
'pg_admin' => 'bg-purple-500',
|
||||||
|
'gate_officer' => 'bg-amber-500',
|
||||||
|
default => 'bg-slate-400'
|
||||||
|
};
|
||||||
|
@endphp
|
||||||
|
<div>
|
||||||
|
<div class="flex items-center justify-between text-xs mb-1">
|
||||||
|
<span class="font-semibold text-slate-700 capitalize">
|
||||||
|
{{ str_replace('_', ' ', $roleName) }}
|
||||||
|
</span>
|
||||||
|
<span class="font-bold text-slate-900">{{ $count }} ({{ $percentage }}%)</span>
|
||||||
|
</div>
|
||||||
|
<div class="w-full bg-slate-100 rounded-full h-2 overflow-hidden">
|
||||||
|
<div class="{{ $badgeColor }} h-2 rounded-full transition-all duration-500" style="width: {{ $percentage }}%"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-6 pt-4 border-t border-slate-100">
|
||||||
|
<a href="{{ route('admin.roles.index') }}" class="text-xs font-bold text-indigo-600 hover:text-indigo-800 flex items-center justify-between">
|
||||||
|
<span>Lihat Konfigurasi Matriks Role</span>
|
||||||
|
<i class="fa-solid fa-arrow-right text-[11px]"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Akun Pengguna Terbaru -->
|
||||||
|
<div class="bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm lg:col-span-2">
|
||||||
|
<div class="flex items-center justify-between mb-4">
|
||||||
|
<h2 class="text-sm font-bold text-slate-800 flex items-center gap-2">
|
||||||
|
<i class="fa-solid fa-user-clock text-slate-400"></i>
|
||||||
|
Pengguna Sistem Terdaftar Terbaru
|
||||||
|
</h2>
|
||||||
|
<a href="{{ route('admin.users.index') }}" class="text-xs font-bold text-indigo-600 hover:text-indigo-800">
|
||||||
|
Lihat Semua User →
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="overflow-x-auto">
|
||||||
|
<table class="w-full text-left text-xs">
|
||||||
|
<thead>
|
||||||
|
<tr class="border-b border-slate-100 text-slate-400 font-semibold">
|
||||||
|
<th class="pb-2.5">Nama & Username</th>
|
||||||
|
<th class="pb-2.5">Email</th>
|
||||||
|
<th class="pb-2.5">Role</th>
|
||||||
|
<th class="pb-2.5">Pos Gerbang</th>
|
||||||
|
<th class="pb-2.5 text-right">Terdaftar</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="divide-y divide-slate-50">
|
||||||
|
@forelse($recentUsers as $user)
|
||||||
|
<tr class="hover:bg-slate-50/60 transition">
|
||||||
|
<td class="py-2.5 pr-2">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<div class="w-7 h-7 rounded-full bg-indigo-50 text-indigo-700 font-bold flex items-center justify-center text-[10px] flex-shrink-0">
|
||||||
|
{{ strtoupper(substr($user->name, 0, 1)) }}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="font-bold text-slate-800">{{ $user->name }}</p>
|
||||||
|
<p class="text-[10px] text-slate-400 font-mono">{{ $user->username }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="py-2.5 pr-2 text-slate-600">{{ $user->email }}</td>
|
||||||
|
<td class="py-2.5 pr-2">
|
||||||
|
@php
|
||||||
|
$primaryRole = $user->roles->first()?->name ?? $user->role;
|
||||||
|
$badgeStyle = match($primaryRole) {
|
||||||
|
'super_admin' => 'bg-indigo-50 text-indigo-700 border-indigo-200',
|
||||||
|
'hse_admin' => 'bg-emerald-50 text-emerald-700 border-emerald-200',
|
||||||
|
'qma_admin' => 'bg-blue-50 text-blue-700 border-blue-200',
|
||||||
|
'pg_admin' => 'bg-purple-50 text-purple-700 border-purple-200',
|
||||||
|
'gate_officer' => 'bg-amber-50 text-amber-700 border-amber-200',
|
||||||
|
default => 'bg-slate-100 text-slate-600 border-slate-200',
|
||||||
|
};
|
||||||
|
@endphp
|
||||||
|
<span class="px-2 py-0.5 rounded-full text-[10px] font-bold border {{ $badgeStyle }} capitalize">
|
||||||
|
{{ str_replace('_', ' ', $primaryRole) }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="py-2.5 pr-2 text-slate-600">
|
||||||
|
{{ $user->gate?->name ?? '-' }}
|
||||||
|
</td>
|
||||||
|
<td class="py-2.5 text-right text-slate-400 text-[11px]">
|
||||||
|
{{ $user->created_at->diffForHumans() }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="5" class="py-4 text-center text-slate-400">Belum ada data pengguna.</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
@@ -0,0 +1,286 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'Matriks Role & Permission (RBAC) - Super Admin RKM')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="space-y-6">
|
||||||
|
<!-- Header Halaman -->
|
||||||
|
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
|
||||||
|
<div>
|
||||||
|
<h1 class="text-2xl font-black text-slate-800 tracking-tight flex items-center gap-2.5">
|
||||||
|
<span class="w-2.5 h-7 rounded-full bg-indigo-600 inline-block"></span>
|
||||||
|
Matriks Role & Hak Akses (RBAC)
|
||||||
|
</h1>
|
||||||
|
<p class="text-xs text-slate-500 mt-1">
|
||||||
|
Konfigurasi izin wewenang (permissions) untuk setiap role pengguna menggunakan paket Spatie Laravel Permission.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-2.5">
|
||||||
|
<button type="button"
|
||||||
|
onclick="openCreateRoleModal()"
|
||||||
|
class="inline-flex items-center gap-2 px-4 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-sm transition">
|
||||||
|
<i class="fa-solid fa-plus text-sm"></i>
|
||||||
|
<span>Tambah Role Baru</span>
|
||||||
|
</button>
|
||||||
|
<a href="{{ route('admin.users.index') }}"
|
||||||
|
class="inline-flex items-center gap-2 px-4 py-2.5 bg-white border border-slate-200 hover:bg-slate-50 text-slate-700 rounded-xl text-xs font-bold shadow-sm transition">
|
||||||
|
<i class="fa-solid fa-users text-indigo-600 text-sm"></i>
|
||||||
|
<span>Kelola Pengguna</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Alert Notifikasi Flash -->
|
||||||
|
@if(session('success'))
|
||||||
|
<div class="p-4 bg-emerald-50 border border-emerald-200 rounded-2xl flex items-center justify-between text-emerald-800 text-xs font-semibold">
|
||||||
|
<div class="flex items-center gap-2.5">
|
||||||
|
<i class="fa-solid fa-circle-check text-emerald-600 text-base"></i>
|
||||||
|
<span>{{ session('success') }}</span>
|
||||||
|
</div>
|
||||||
|
<button type="button" onclick="this.parentElement.remove()" class="text-emerald-500 hover:text-emerald-700">
|
||||||
|
<i class="fa-solid fa-xmark"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if(session('error'))
|
||||||
|
<div class="p-4 bg-rose-50 border border-rose-200 rounded-2xl flex items-center justify-between text-rose-800 text-xs font-semibold">
|
||||||
|
<div class="flex items-center gap-2.5">
|
||||||
|
<i class="fa-solid fa-triangle-exclamation text-rose-600 text-base"></i>
|
||||||
|
<span>{{ session('error') }}</span>
|
||||||
|
</div>
|
||||||
|
<button type="button" onclick="this.parentElement.remove()" class="text-rose-500 hover:text-rose-700">
|
||||||
|
<i class="fa-solid fa-xmark"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Info Box: Super Admin Priviledge -->
|
||||||
|
<div class="p-4 bg-indigo-50/70 border border-indigo-100 rounded-2xl flex items-start gap-3.5 text-xs text-indigo-900">
|
||||||
|
<div class="w-8 h-8 rounded-xl bg-indigo-600 text-white flex items-center justify-center flex-shrink-0 text-sm shadow-sm">
|
||||||
|
<i class="fa-solid fa-crown"></i>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h2 class="font-bold text-indigo-950">Privilese Khusus Super Administrator (Gate::before Bypass)</h2>
|
||||||
|
<p class="text-indigo-800/80 mt-0.5 leading-relaxed">
|
||||||
|
Role <strong>super_admin</strong> secara otomatis memiliki hak akses tak terbatas ke seluruh modul sistem (HSE, QMA, PG, dan Pengaturan RBAC) melalui interceptor gerbang Laravel. Matriks centang di bawah ini berlaku aktif untuk role operasional lainnya.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Ringkasan Role Cards -->
|
||||||
|
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3">
|
||||||
|
@foreach($roles as $role)
|
||||||
|
@php
|
||||||
|
$isCoreRole = in_array($role->name, ['super_admin', 'hse_admin', 'qma_admin', 'pg_admin', 'gate_officer']);
|
||||||
|
$badgeColor = match($role->name) {
|
||||||
|
'super_admin' => 'bg-indigo-600 text-white',
|
||||||
|
'hse_admin' => 'bg-emerald-600 text-white',
|
||||||
|
'qma_admin' => 'bg-blue-600 text-white',
|
||||||
|
'pg_admin' => 'bg-purple-600 text-white',
|
||||||
|
'gate_officer' => 'bg-amber-600 text-white',
|
||||||
|
default => 'bg-slate-700 text-white'
|
||||||
|
};
|
||||||
|
@endphp
|
||||||
|
<div class="bg-white border border-slate-200/80 rounded-2xl p-4 shadow-sm flex flex-col justify-between">
|
||||||
|
<div>
|
||||||
|
<div class="flex items-center justify-between mb-2">
|
||||||
|
<span class="w-2.5 h-2.5 rounded-full {{ $badgeColor }}"></span>
|
||||||
|
@if(!$isCoreRole)
|
||||||
|
<button type="button"
|
||||||
|
onclick='openDeleteRoleModal({{ $role->id }}, "{{ $role->name }}")'
|
||||||
|
class="text-slate-400 hover:text-rose-600 transition"
|
||||||
|
title="Hapus Role Kustom">
|
||||||
|
<i class="fa-solid fa-trash-can text-xs"></i>
|
||||||
|
</button>
|
||||||
|
@else
|
||||||
|
<span class="text-[9px] font-bold text-slate-400 uppercase tracking-wider">Core</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<h2 class="text-xs font-bold text-slate-800 capitalize">{{ str_replace('_', ' ', $role->name) }}</h2>
|
||||||
|
<p class="text-[10px] text-slate-400 mt-0.5 font-mono">{{ $role->name }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="mt-3 pt-2.5 border-t border-slate-100 flex items-center justify-between text-[11px]">
|
||||||
|
<span class="text-slate-500">Izin Aktif:</span>
|
||||||
|
<span class="font-bold text-indigo-700">
|
||||||
|
{{ $role->name === 'super_admin' ? 'Semua' : $role->permissions->count() }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Matriks Role & Permissions Table -->
|
||||||
|
<div class="space-y-6">
|
||||||
|
@foreach($roles as $role)
|
||||||
|
<div class="bg-white border border-slate-200/80 rounded-2xl shadow-sm overflow-hidden">
|
||||||
|
<div class="px-5 py-3.5 bg-slate-50 border-b border-slate-100 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<div class="w-8 h-8 rounded-xl bg-indigo-50 border border-indigo-100 text-indigo-700 flex items-center justify-center font-bold text-xs">
|
||||||
|
<i class="fa-solid fa-shield-halved"></i>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h2 class="text-sm font-bold text-slate-900 capitalize flex items-center gap-2">
|
||||||
|
<span>Role: {{ str_replace('_', ' ', $role->name) }}</span>
|
||||||
|
@if($role->name === 'super_admin')
|
||||||
|
<span class="px-2 py-0.5 rounded-full text-[9px] font-black bg-indigo-100 text-indigo-800">UNRESTRICTED</span>
|
||||||
|
@endif
|
||||||
|
</h2>
|
||||||
|
<p class="text-[11px] text-slate-400">Atur centang hak akses yang diizinkan untuk peran pengguna ini.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if($role->name !== 'super_admin')
|
||||||
|
<button type="submit"
|
||||||
|
form="form-role-{{ $role->id }}"
|
||||||
|
class="inline-flex items-center gap-1.5 px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-sm transition self-end sm:self-auto">
|
||||||
|
<i class="fa-solid fa-floppy-disk"></i>
|
||||||
|
<span>Simpan Hak Akses</span>
|
||||||
|
</button>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="form-role-{{ $role->id }}"
|
||||||
|
action="{{ route('admin.roles.permissions.update', $role->id) }}"
|
||||||
|
method="POST"
|
||||||
|
class="p-5">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
@php
|
||||||
|
$rolePermNames = $role->permissions->pluck('name')->toArray();
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||||
|
@foreach($modules as $moduleKey => $module)
|
||||||
|
<div class="bg-slate-50/70 border border-slate-200/60 rounded-xl p-4 space-y-3">
|
||||||
|
<h3 class="text-xs font-bold text-slate-800 flex items-center justify-between pb-2 border-b border-slate-200/60">
|
||||||
|
<span class="flex items-center gap-1.5">
|
||||||
|
<i class="{{ $module['icon'] }} text-indigo-600 text-xs"></i>
|
||||||
|
<span>{{ $module['name'] }}</span>
|
||||||
|
</span>
|
||||||
|
<span class="text-[10px] text-slate-400 font-semibold">{{ count($module['permissions']) }} izin</span>
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<div class="space-y-2">
|
||||||
|
@foreach($module['permissions'] as $permKey => $permMeta)
|
||||||
|
@php
|
||||||
|
$isChecked = $role->name === 'super_admin' || in_array($permKey, $rolePermNames);
|
||||||
|
@endphp
|
||||||
|
<label class="flex items-start gap-2.5 text-xs text-slate-700 cursor-pointer select-none group p-2 rounded-lg hover:bg-white hover:shadow-xs border border-transparent hover:border-slate-200/60 transition">
|
||||||
|
<input type="checkbox"
|
||||||
|
name="permissions[]"
|
||||||
|
value="{{ $permKey }}"
|
||||||
|
{{ $isChecked ? 'checked' : '' }}
|
||||||
|
{{ $role->name === 'super_admin' ? 'disabled' : '' }}
|
||||||
|
class="mt-1 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500 transition">
|
||||||
|
<div>
|
||||||
|
<span class="text-xs font-bold text-slate-800 group-hover:text-indigo-600 transition block">
|
||||||
|
{{ $permMeta['label'] }}
|
||||||
|
</span>
|
||||||
|
<p class="text-[11px] text-slate-500 mt-0.5 leading-snug">
|
||||||
|
{{ $permMeta['description'] }}
|
||||||
|
</p>
|
||||||
|
<span class="font-mono text-[10px] text-slate-400 mt-1 block">
|
||||||
|
{{ $permKey }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ========================================================================= -->
|
||||||
|
<!-- MODAL: TAMBAH ROLE BARU -->
|
||||||
|
<!-- ========================================================================= -->
|
||||||
|
<div id="createRoleModal" class="fixed inset-0 z-50 hidden overflow-y-auto bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4">
|
||||||
|
<div class="bg-white rounded-2xl max-w-sm w-full shadow-2xl overflow-hidden animate-scale-in">
|
||||||
|
<div class="px-5 py-4 border-b border-slate-100 flex items-center justify-between">
|
||||||
|
<h3 class="text-sm font-bold text-slate-800 flex items-center gap-2">
|
||||||
|
<i class="fa-solid fa-shield-plus text-indigo-600"></i>
|
||||||
|
Tambah Role Baru
|
||||||
|
</h3>
|
||||||
|
<button type="button" onclick="closeCreateRoleModal()" class="text-slate-400 hover:text-slate-600">
|
||||||
|
<i class="fa-solid fa-xmark text-base"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form action="{{ route('admin.roles.store') }}" method="POST" class="p-5 space-y-4">
|
||||||
|
@csrf
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-slate-700 mb-1">Nama Role *</label>
|
||||||
|
<input type="text" name="name" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white" placeholder="Contoh: auditor_internal">
|
||||||
|
<p class="text-[10px] text-slate-400 mt-1">Gunakan huruf kecil atau underscore (contoh: staff_logistik).</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pt-3 border-t border-slate-100 flex items-center justify-end gap-2">
|
||||||
|
<button type="button" onclick="closeCreateRoleModal()" class="px-4 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-xl text-xs font-bold transition">
|
||||||
|
Batal
|
||||||
|
</button>
|
||||||
|
<button type="submit" class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-sm transition">
|
||||||
|
Simpan Role
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ========================================================================= -->
|
||||||
|
<!-- MODAL: HAPUS ROLE -->
|
||||||
|
<!-- ========================================================================= -->
|
||||||
|
<div id="deleteRoleModal" class="fixed inset-0 z-50 hidden overflow-y-auto bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4">
|
||||||
|
<div class="bg-white rounded-2xl max-w-sm w-full shadow-2xl overflow-hidden p-6 text-center animate-scale-in">
|
||||||
|
<div class="w-12 h-12 rounded-full bg-rose-50 text-rose-600 flex items-center justify-center mx-auto mb-3 text-xl">
|
||||||
|
<i class="fa-solid fa-trash-can"></i>
|
||||||
|
</div>
|
||||||
|
<h3 class="text-sm font-bold text-slate-800 mb-1">Hapus Role Kustom</h3>
|
||||||
|
<p class="text-xs text-slate-500 mb-5">
|
||||||
|
Apakah Anda yakin ingin menghapus role <strong id="deleteRoleName" class="text-slate-800"></strong>?
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<form id="deleteRoleForm" method="POST">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<div class="flex items-center justify-center gap-2.5">
|
||||||
|
<button type="button" onclick="closeDeleteRoleModal()" class="px-4 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-xl text-xs font-bold transition">
|
||||||
|
Batal
|
||||||
|
</button>
|
||||||
|
<button type="submit" class="px-4 py-2 bg-rose-600 hover:bg-rose-700 text-white rounded-xl text-xs font-bold shadow-sm transition">
|
||||||
|
Ya, Hapus Role
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function openCreateRoleModal() {
|
||||||
|
document.getElementById('createRoleModal').classList.remove('hidden');
|
||||||
|
document.documentElement.classList.add('modal-open');
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeCreateRoleModal() {
|
||||||
|
document.getElementById('createRoleModal').classList.add('hidden');
|
||||||
|
document.documentElement.classList.remove('modal-open');
|
||||||
|
}
|
||||||
|
|
||||||
|
function openDeleteRoleModal(roleId, roleName) {
|
||||||
|
document.getElementById('deleteRoleForm').action = `/admin/roles/${roleId}`;
|
||||||
|
document.getElementById('deleteRoleName').textContent = roleName;
|
||||||
|
|
||||||
|
document.getElementById('deleteRoleModal').classList.remove('hidden');
|
||||||
|
document.documentElement.classList.add('modal-open');
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeDeleteRoleModal() {
|
||||||
|
document.getElementById('deleteRoleModal').classList.add('hidden');
|
||||||
|
document.documentElement.classList.remove('modal-open');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@endsection
|
||||||
@@ -0,0 +1,490 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'Manajemen Pengguna - Super Admin RKM')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="space-y-6">
|
||||||
|
<!-- Header Halaman -->
|
||||||
|
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
|
||||||
|
<div>
|
||||||
|
<h1 class="text-2xl font-black text-slate-800 tracking-tight flex items-center gap-2.5">
|
||||||
|
<span class="w-2.5 h-7 rounded-full bg-indigo-600 inline-block"></span>
|
||||||
|
Manajemen Pengguna Sistem
|
||||||
|
</h1>
|
||||||
|
<p class="text-xs text-slate-500 mt-1">
|
||||||
|
Kelola akun pengguna, ganti kata sandi, dan tetapkan role wewenang pada sistem RKM-KMH.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button type="button"
|
||||||
|
onclick="openCreateUserModal()"
|
||||||
|
class="inline-flex items-center gap-2 px-4 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-sm transition">
|
||||||
|
<i class="fa-solid fa-user-plus text-sm"></i>
|
||||||
|
<span>Tambah Pengguna Baru</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Alert Notifikasi Flash -->
|
||||||
|
@if(session('success'))
|
||||||
|
<div class="p-4 bg-emerald-50 border border-emerald-200 rounded-2xl flex items-center justify-between text-emerald-800 text-xs font-semibold">
|
||||||
|
<div class="flex items-center gap-2.5">
|
||||||
|
<i class="fa-solid fa-circle-check text-emerald-600 text-base"></i>
|
||||||
|
<span>{{ session('success') }}</span>
|
||||||
|
</div>
|
||||||
|
<button type="button" onclick="this.parentElement.remove()" class="text-emerald-500 hover:text-emerald-700">
|
||||||
|
<i class="fa-solid fa-xmark"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if(session('error'))
|
||||||
|
<div class="p-4 bg-rose-50 border border-rose-200 rounded-2xl flex items-center justify-between text-rose-800 text-xs font-semibold">
|
||||||
|
<div class="flex items-center gap-2.5">
|
||||||
|
<i class="fa-solid fa-triangle-exclamation text-rose-600 text-base"></i>
|
||||||
|
<span>{{ session('error') }}</span>
|
||||||
|
</div>
|
||||||
|
<button type="button" onclick="this.parentElement.remove()" class="text-rose-500 hover:text-rose-700">
|
||||||
|
<i class="fa-solid fa-xmark"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if($errors->any())
|
||||||
|
<div class="p-4 bg-rose-50 border border-rose-200 rounded-2xl text-rose-800 text-xs">
|
||||||
|
<div class="flex items-center gap-2 font-bold mb-1">
|
||||||
|
<i class="fa-solid fa-circle-xmark text-rose-600"></i>
|
||||||
|
<span>Terdapat kesalahan pada input Anda:</span>
|
||||||
|
</div>
|
||||||
|
<ul class="list-disc list-inside space-y-0.5 text-rose-700">
|
||||||
|
@foreach($errors->all() as $err)
|
||||||
|
<li>{{ $err }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Card Filter & Pencarian -->
|
||||||
|
<div class="bg-white border border-slate-200/80 rounded-2xl p-4 shadow-sm">
|
||||||
|
<form method="GET" action="{{ route('admin.users.index') }}" class="flex flex-col sm:flex-row gap-3">
|
||||||
|
<div class="flex-1 relative">
|
||||||
|
<i class="fa-solid fa-magnifying-glass absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||||
|
<input type="text"
|
||||||
|
name="search"
|
||||||
|
value="{{ request('search') }}"
|
||||||
|
placeholder="Cari nama, username, atau email pengguna..."
|
||||||
|
class="w-full pl-9 pr-4 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white transition">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="w-full sm:w-48">
|
||||||
|
<select name="role" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white transition">
|
||||||
|
<option value="">-- Semua Role --</option>
|
||||||
|
@foreach($roles as $role)
|
||||||
|
<option value="{{ $role->name }}" {{ request('role') === $role->name ? 'selected' : '' }}>
|
||||||
|
{{ ucwords(str_replace('_', ' ', $role->name)) }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<button type="submit" class="px-4 py-2 bg-slate-800 hover:bg-slate-900 text-white rounded-xl text-xs font-bold transition flex items-center gap-2">
|
||||||
|
<i class="fa-solid fa-filter"></i>
|
||||||
|
<span>Filter</span>
|
||||||
|
</button>
|
||||||
|
@if(request()->hasAny(['search', 'role']))
|
||||||
|
<a href="{{ route('admin.users.index') }}" class="px-3 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-xl text-xs font-semibold transition" title="Reset Filter">
|
||||||
|
<i class="fa-solid fa-arrow-rotate-left"></i>
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Tabel Data Pengguna -->
|
||||||
|
<div class="bg-white border border-slate-200/80 rounded-2xl shadow-sm overflow-hidden">
|
||||||
|
<div class="overflow-x-auto">
|
||||||
|
<table class="w-full text-left text-xs">
|
||||||
|
<thead>
|
||||||
|
<tr class="bg-slate-50 border-b border-slate-100 text-slate-500 font-bold uppercase tracking-wider text-[11px]">
|
||||||
|
<th class="py-3 px-4">Pengguna</th>
|
||||||
|
<th class="py-3 px-4">Email</th>
|
||||||
|
<th class="py-3 px-4">Role RBAC</th>
|
||||||
|
<th class="py-3 px-4">Penempatan Pos</th>
|
||||||
|
<th class="py-3 px-4">Terdaftar</th>
|
||||||
|
<th class="py-3 px-4 text-center">Aksi</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="divide-y divide-slate-100 font-medium">
|
||||||
|
@forelse($users as $user)
|
||||||
|
@php
|
||||||
|
$primaryRole = $user->roles->first()?->name ?? $user->role;
|
||||||
|
$badgeStyle = match($primaryRole) {
|
||||||
|
'super_admin' => 'bg-indigo-50 text-indigo-700 border-indigo-200',
|
||||||
|
'hse_admin' => 'bg-emerald-50 text-emerald-700 border-emerald-200',
|
||||||
|
'qma_admin' => 'bg-blue-50 text-blue-700 border-blue-200',
|
||||||
|
'pg_admin' => 'bg-purple-50 text-purple-700 border-purple-200',
|
||||||
|
'gate_officer' => 'bg-amber-50 text-amber-700 border-amber-200',
|
||||||
|
default => 'bg-slate-100 text-slate-600 border-slate-200',
|
||||||
|
};
|
||||||
|
@endphp
|
||||||
|
<tr class="hover:bg-slate-50/70 transition">
|
||||||
|
<td class="py-3 px-4">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<div class="w-8 h-8 rounded-full bg-indigo-50 border border-indigo-100 text-indigo-700 font-black flex items-center justify-center text-xs flex-shrink-0">
|
||||||
|
{{ strtoupper(substr($user->name, 0, 1)) }}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="font-bold text-slate-900 text-xs">{{ $user->name }}</p>
|
||||||
|
<p class="text-[11px] text-slate-400 font-mono">@<span>{{ $user->username }}</span></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="py-3 px-4 text-slate-600 font-normal">
|
||||||
|
{{ $user->email }}
|
||||||
|
</td>
|
||||||
|
<td class="py-3 px-4">
|
||||||
|
<div class="flex flex-col gap-1 items-start">
|
||||||
|
<span class="px-2.5 py-1 rounded-full text-[10px] font-bold border {{ $badgeStyle }} capitalize">
|
||||||
|
{{ str_replace('_', ' ', $primaryRole) }}
|
||||||
|
</span>
|
||||||
|
@if($user->permissions->count() > 0)
|
||||||
|
<span class="inline-flex items-center gap-1 text-[10px] font-semibold text-indigo-700 bg-indigo-50/90 px-2 py-0.5 rounded-md border border-indigo-100" title="{{ $user->permissions->pluck('name')->implode(', ') }}">
|
||||||
|
<i class="fa-solid fa-key text-[9px]"></i>
|
||||||
|
+{{ $user->permissions->count() }} Izin Khusus
|
||||||
|
</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="py-3 px-4 text-slate-600">
|
||||||
|
@if($user->gate)
|
||||||
|
<span class="inline-flex items-center gap-1.5 text-xs text-slate-700">
|
||||||
|
<i class="fa-solid fa-location-dot text-slate-400"></i>
|
||||||
|
{{ $user->gate->name }}
|
||||||
|
</span>
|
||||||
|
@else
|
||||||
|
<span class="text-slate-400 text-[11px]">-</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td class="py-3 px-4 text-slate-500 text-[11px]">
|
||||||
|
{{ $user->created_at->format('d M Y') }}
|
||||||
|
</td>
|
||||||
|
<td class="py-3 px-4 text-center">
|
||||||
|
<div class="inline-flex items-center gap-1.5">
|
||||||
|
<button type="button"
|
||||||
|
onclick='openEditUserModal(@json($user), "{{ $primaryRole }}", @json($user->permissions->pluck("name")))'
|
||||||
|
class="w-7 h-7 rounded-lg bg-slate-100 hover:bg-indigo-50 text-slate-600 hover:text-indigo-600 flex items-center justify-center transition"
|
||||||
|
title="Edit Pengguna">
|
||||||
|
<i class="fa-solid fa-pen-to-square text-xs"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
@if($user->id !== auth()->id() && $user->username !== 'superadmin')
|
||||||
|
<button type="button"
|
||||||
|
onclick='openDeleteUserModal({{ $user->id }}, "{{ addslashes($user->name) }}")'
|
||||||
|
class="w-7 h-7 rounded-lg bg-slate-100 hover:bg-rose-50 text-slate-600 hover:text-rose-600 flex items-center justify-center transition"
|
||||||
|
title="Hapus Pengguna">
|
||||||
|
<i class="fa-solid fa-trash-can text-xs"></i>
|
||||||
|
</button>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="6" class="py-8 text-center text-slate-400">
|
||||||
|
<i class="fa-solid fa-user-slash text-2xl mb-2 text-slate-300 block"></i>
|
||||||
|
Tidak ada data pengguna yang sesuai kriteria pencarian.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if($users->hasPages())
|
||||||
|
<div class="p-4 border-t border-slate-100">
|
||||||
|
{{ $users->links() }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ========================================================================= -->
|
||||||
|
<!-- MODAL: TAMBAH PENGGUNA BARU -->
|
||||||
|
<!-- ========================================================================= -->
|
||||||
|
<div id="createUserModal" class="fixed inset-0 z-50 hidden overflow-y-auto bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4">
|
||||||
|
<div class="bg-white rounded-2xl max-w-lg w-full shadow-2xl overflow-hidden animate-scale-in">
|
||||||
|
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between">
|
||||||
|
<h3 class="text-sm font-bold text-slate-800 flex items-center gap-2">
|
||||||
|
<i class="fa-solid fa-user-plus text-indigo-600"></i>
|
||||||
|
Tambah Pengguna Baru
|
||||||
|
</h3>
|
||||||
|
<button type="button" onclick="closeCreateUserModal()" class="text-slate-400 hover:text-slate-600">
|
||||||
|
<i class="fa-solid fa-xmark text-base"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form action="{{ route('admin.users.store') }}" method="POST" class="p-6 space-y-4">
|
||||||
|
@csrf
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-slate-700 mb-1">Nama Lengkap *</label>
|
||||||
|
<input type="text" name="name" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white" placeholder="Contoh: Ahmad Rizky">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-2 gap-3">
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-slate-700 mb-1">Username *</label>
|
||||||
|
<input type="text" name="username" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white" placeholder="Contoh: ahmad.rizky">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-slate-700 mb-1">Email *</label>
|
||||||
|
<input type="email" name="email" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white" placeholder="[email protected]">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-slate-700 mb-1">Password *</label>
|
||||||
|
<input type="password" name="password" required minlength="6" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white" placeholder="Minimal 6 karakter">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-2 gap-3">
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-slate-700 mb-1">Role RBAC *</label>
|
||||||
|
<select name="role" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white">
|
||||||
|
<option value="">-- Pilih Role --</option>
|
||||||
|
@foreach($roles as $role)
|
||||||
|
<option value="{{ $role->name }}">{{ ucwords(str_replace('_', ' ', $role->name)) }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-slate-700 mb-1">Penempatan Pos Gerbang</label>
|
||||||
|
<select name="gate_id" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white">
|
||||||
|
<option value="">-- Tanpa Pos Gerbang --</option>
|
||||||
|
@foreach($gates as $gate)
|
||||||
|
<option value="{{ $gate->id }}">{{ $gate->name }} ({{ $gate->code }})</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pt-4 border-t border-slate-100 flex items-center justify-end gap-2.5">
|
||||||
|
<button type="button" onclick="closeCreateUserModal()" class="px-4 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-xl text-xs font-bold transition">
|
||||||
|
Batal
|
||||||
|
</button>
|
||||||
|
<button type="submit" class="px-5 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-sm transition">
|
||||||
|
Simpan Pengguna
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ========================================================================= -->
|
||||||
|
<!-- MODAL: EDIT PENGGUNA -->
|
||||||
|
<!-- ========================================================================= -->
|
||||||
|
<div id="editUserModal" class="fixed inset-0 z-50 hidden overflow-y-auto bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4">
|
||||||
|
<div class="bg-white rounded-2xl max-w-lg w-full shadow-2xl overflow-hidden animate-scale-in">
|
||||||
|
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between">
|
||||||
|
<h3 class="text-sm font-bold text-slate-800 flex items-center gap-2">
|
||||||
|
<i class="fa-solid fa-user-pen text-indigo-600"></i>
|
||||||
|
Edit Data Pengguna
|
||||||
|
</h3>
|
||||||
|
<button type="button" onclick="closeEditUserModal()" class="text-slate-400 hover:text-slate-600">
|
||||||
|
<i class="fa-solid fa-xmark text-base"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="editUserForm" method="POST" class="p-6 space-y-4">
|
||||||
|
@csrf
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-slate-700 mb-1">Nama Lengkap *</label>
|
||||||
|
<input type="text" id="edit_name" name="name" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-2 gap-3">
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-slate-700 mb-1">Username *</label>
|
||||||
|
<input type="text" id="edit_username" name="username" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-slate-700 mb-1">Email *</label>
|
||||||
|
<input type="email" id="edit_email" name="email" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-slate-700 mb-1">
|
||||||
|
Ganti Password <span class="text-slate-400 font-normal">(Kosongkan jika tidak ingin mengubah)</span>
|
||||||
|
</label>
|
||||||
|
<input type="password" name="password" minlength="6" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white" placeholder="Masukkan password baru">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-2 gap-3">
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-slate-700 mb-1">Role RBAC *</label>
|
||||||
|
<select id="edit_role" name="role" required class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white">
|
||||||
|
@foreach($roles as $role)
|
||||||
|
<option value="{{ $role->name }}">{{ ucwords(str_replace('_', ' ', $role->name)) }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-slate-700 mb-1">Penempatan Pos Gerbang</label>
|
||||||
|
<select id="edit_gate_id" name="gate_id" class="w-full px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white">
|
||||||
|
<option value="">-- Tanpa Pos Gerbang --</option>
|
||||||
|
@foreach($gates as $gate)
|
||||||
|
<option value="{{ $gate->id }}">{{ $gate->name }} ({{ $gate->code }})</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Accordion: Izin Tambahan Khusus (Direct Permissions) -->
|
||||||
|
<div class="border border-slate-200 rounded-xl overflow-hidden bg-slate-50/50">
|
||||||
|
<button type="button"
|
||||||
|
onclick="toggleDirectPermsAccordion()"
|
||||||
|
class="w-full px-4 py-2.5 bg-slate-100/70 hover:bg-slate-100 flex items-center justify-between text-xs font-bold text-slate-700 transition">
|
||||||
|
<span class="flex items-center gap-2">
|
||||||
|
<i class="fa-solid fa-key text-indigo-600"></i>
|
||||||
|
<span>Izin Tambahan Khusus (Direct Permissions)</span>
|
||||||
|
</span>
|
||||||
|
<i id="directPermsChevron" class="fa-solid fa-chevron-down text-[10px] text-slate-400 transition-transform duration-200"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div id="directPermsContainer" class="hidden p-4 space-y-4 max-h-56 overflow-y-auto bg-white border-t border-slate-200 text-xs">
|
||||||
|
<p class="text-[11px] text-slate-500 mb-1">
|
||||||
|
Pilih izin individual tambahan di luar wewenang role bawaan pengguna ini:
|
||||||
|
</p>
|
||||||
|
@foreach($modules as $moduleKey => $module)
|
||||||
|
<div class="space-y-1.5 pb-2.5 border-b border-slate-100 last:border-0">
|
||||||
|
<p class="font-bold text-[11px] text-indigo-950 flex items-center gap-1.5">
|
||||||
|
<i class="{{ $module['icon'] }} text-[10px] text-indigo-600"></i>
|
||||||
|
<span>{{ $module['name'] }}</span>
|
||||||
|
</p>
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-1.5 pl-3">
|
||||||
|
@foreach($module['permissions'] as $permKey => $permMeta)
|
||||||
|
<label class="flex items-start gap-2 text-[11px] text-slate-700 cursor-pointer select-none group">
|
||||||
|
<input type="checkbox"
|
||||||
|
name="direct_permissions[]"
|
||||||
|
value="{{ $permKey }}"
|
||||||
|
id="edit_perm_{{ str_replace('.', '_', $permKey) }}"
|
||||||
|
class="mt-0.5 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500 user-direct-perm-checkbox">
|
||||||
|
<div>
|
||||||
|
<span class="font-medium text-slate-800 group-hover:text-indigo-600 transition block">
|
||||||
|
{{ $permMeta['label'] }}
|
||||||
|
</span>
|
||||||
|
<span class="font-mono text-[9px] text-slate-400 block">{{ $permKey }}</span>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pt-4 border-t border-slate-100 flex items-center justify-end gap-2.5">
|
||||||
|
<button type="button" onclick="closeEditUserModal()" class="px-4 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-xl text-xs font-bold transition">
|
||||||
|
Batal
|
||||||
|
</button>
|
||||||
|
<button type="submit" class="px-5 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-sm transition">
|
||||||
|
Simpan Perubahan
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ========================================================================= -->
|
||||||
|
<!-- MODAL: HAPUS PENGGUNA -->
|
||||||
|
<!-- ========================================================================= -->
|
||||||
|
<div id="deleteUserModal" class="fixed inset-0 z-50 hidden overflow-y-auto bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4">
|
||||||
|
<div class="bg-white rounded-2xl max-w-sm w-full shadow-2xl overflow-hidden p-6 text-center animate-scale-in">
|
||||||
|
<div class="w-12 h-12 rounded-full bg-rose-50 text-rose-600 flex items-center justify-center mx-auto mb-3 text-xl">
|
||||||
|
<i class="fa-solid fa-trash-can"></i>
|
||||||
|
</div>
|
||||||
|
<h3 class="text-sm font-bold text-slate-800 mb-1">Hapus Pengguna</h3>
|
||||||
|
<p class="text-xs text-slate-500 mb-5">
|
||||||
|
Apakah Anda yakin ingin menghapus pengguna <strong id="deleteUserName" class="text-slate-800"></strong>? Tindakan ini tidak dapat dibatalkan.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<form id="deleteUserForm" method="POST">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<div class="flex items-center justify-center gap-2.5">
|
||||||
|
<button type="button" onclick="closeDeleteUserModal()" class="px-4 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-xl text-xs font-bold transition">
|
||||||
|
Batal
|
||||||
|
</button>
|
||||||
|
<button type="submit" class="px-4 py-2 bg-rose-600 hover:bg-rose-700 text-white rounded-xl text-xs font-bold shadow-sm transition">
|
||||||
|
Ya, Hapus Pengguna
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function openCreateUserModal() {
|
||||||
|
document.getElementById('createUserModal').classList.remove('hidden');
|
||||||
|
document.documentElement.classList.add('modal-open');
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeCreateUserModal() {
|
||||||
|
document.getElementById('createUserModal').classList.add('hidden');
|
||||||
|
document.documentElement.classList.remove('modal-open');
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleDirectPermsAccordion() {
|
||||||
|
const container = document.getElementById('directPermsContainer');
|
||||||
|
const chevron = document.getElementById('directPermsChevron');
|
||||||
|
if (container) {
|
||||||
|
container.classList.toggle('hidden');
|
||||||
|
}
|
||||||
|
if (chevron) {
|
||||||
|
chevron.classList.toggle('rotate-180');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openEditUserModal(user, primaryRole, userDirectPerms) {
|
||||||
|
document.getElementById('editUserForm').action = `/admin/users/${user.id}`;
|
||||||
|
document.getElementById('edit_name').value = user.name;
|
||||||
|
document.getElementById('edit_username').value = user.username;
|
||||||
|
document.getElementById('edit_email').value = user.email;
|
||||||
|
document.getElementById('edit_role').value = primaryRole;
|
||||||
|
document.getElementById('edit_gate_id').value = user.gate_id || '';
|
||||||
|
|
||||||
|
// Uncheck all direct permission checkboxes first
|
||||||
|
document.querySelectorAll('.user-direct-perm-checkbox').forEach(cb => cb.checked = false);
|
||||||
|
|
||||||
|
// Check assigned direct permissions
|
||||||
|
if (Array.isArray(userDirectPerms)) {
|
||||||
|
userDirectPerms.forEach(permName => {
|
||||||
|
const el = document.getElementById('edit_perm_' + permName.replace(/\./g, '_'));
|
||||||
|
if (el) el.checked = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('editUserModal').classList.remove('hidden');
|
||||||
|
document.documentElement.classList.add('modal-open');
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeEditUserModal() {
|
||||||
|
document.getElementById('editUserModal').classList.add('hidden');
|
||||||
|
document.documentElement.classList.remove('modal-open');
|
||||||
|
}
|
||||||
|
|
||||||
|
function openDeleteUserModal(userId, userName) {
|
||||||
|
document.getElementById('deleteUserForm').action = `/admin/users/${userId}`;
|
||||||
|
document.getElementById('deleteUserName').textContent = userName;
|
||||||
|
|
||||||
|
document.getElementById('deleteUserModal').classList.remove('hidden');
|
||||||
|
document.documentElement.classList.add('modal-open');
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeDeleteUserModal() {
|
||||||
|
document.getElementById('deleteUserModal').classList.add('hidden');
|
||||||
|
document.documentElement.classList.remove('modal-open');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@endsection
|
||||||
@@ -37,12 +37,14 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<!-- Tombol Tambah Karyawan (+ Tambah Karyawan Hijau Tua) -->
|
<!-- Tombol Tambah Karyawan (+ Tambah Karyawan Hijau Tua) -->
|
||||||
|
@can('hse.employees.create')
|
||||||
<button type="button"
|
<button type="button"
|
||||||
onclick="document.getElementById('addKaryawanModal').classList.remove('hidden')"
|
onclick="document.getElementById('addKaryawanModal').classList.remove('hidden')"
|
||||||
class="w-full sm:w-auto bg-[#1b5e20] hover:bg-[#144919] text-white px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold flex items-center justify-center space-x-2 transition shadow-sm">
|
class="w-full sm:w-auto bg-[#1b5e20] hover:bg-[#144919] text-white px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold flex items-center justify-center space-x-2 transition shadow-sm">
|
||||||
<i class="fa-solid fa-plus text-xs"></i>
|
<i class="fa-solid fa-plus text-xs"></i>
|
||||||
<span>Tambah Karyawan</span>
|
<span>Tambah Karyawan</span>
|
||||||
</button>
|
</button>
|
||||||
|
@endcan
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -173,6 +175,7 @@
|
|||||||
|
|
||||||
<!-- Aksi (Edit Data Simper & Perpanjang SIMPER) -->
|
<!-- Aksi (Edit Data Simper & Perpanjang SIMPER) -->
|
||||||
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
||||||
|
@can('hse.employees.edit')
|
||||||
<div class="flex items-center justify-center space-x-2">
|
<div class="flex items-center justify-center space-x-2">
|
||||||
<button onclick='openEditModal(@json($emp))'
|
<button onclick='openEditModal(@json($emp))'
|
||||||
class="inline-flex items-center space-x-1 text-amber-500 hover:text-amber-700 hover:bg-amber-50 px-2 py-1 rounded-lg transition"
|
class="inline-flex items-center space-x-1 text-amber-500 hover:text-amber-700 hover:bg-amber-50 px-2 py-1 rounded-lg transition"
|
||||||
@@ -187,6 +190,9 @@
|
|||||||
Perpanjang
|
Perpanjang
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@else
|
||||||
|
<span class="text-xs text-slate-400 italic">Hanya lihat</span>
|
||||||
|
@endcan
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@empty
|
@empty
|
||||||
|
|||||||
@@ -139,7 +139,19 @@
|
|||||||
<!-- Grup: Navigasi Utama -->
|
<!-- Grup: Navigasi Utama -->
|
||||||
<div>
|
<div>
|
||||||
<nav class="space-y-1">
|
<nav class="space-y-1">
|
||||||
@if(auth()->user()->isHseAdmin())
|
@if(auth()->user()->isSuperAdmin())
|
||||||
|
<a href="{{ route('admin.dashboard') }}"
|
||||||
|
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('admin.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
|
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
|
||||||
|
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
|
||||||
|
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
|
||||||
|
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
|
||||||
|
</svg>
|
||||||
|
<span>Dashboard Admin</span>
|
||||||
|
</a>
|
||||||
|
@elseif(auth()->user()->isHseAdmin())
|
||||||
|
@can('hse.employees.view')
|
||||||
<a href="{{ route('hse.dashboard') }}"
|
<a href="{{ route('hse.dashboard') }}"
|
||||||
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('hse.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('hse.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
@@ -150,7 +162,9 @@
|
|||||||
</svg>
|
</svg>
|
||||||
<span>Dashboard</span>
|
<span>Dashboard</span>
|
||||||
</a>
|
</a>
|
||||||
|
@endcan
|
||||||
@elseif(auth()->user()->isQmaAdmin())
|
@elseif(auth()->user()->isQmaAdmin())
|
||||||
|
@can('qma.vehicles.view')
|
||||||
<a href="{{ route('qma.dashboard') }}"
|
<a href="{{ route('qma.dashboard') }}"
|
||||||
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('qma.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('qma.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
@@ -161,7 +175,9 @@
|
|||||||
</svg>
|
</svg>
|
||||||
<span>Dashboard</span>
|
<span>Dashboard</span>
|
||||||
</a>
|
</a>
|
||||||
|
@endcan
|
||||||
@elseif(auth()->user()->isPgAdmin())
|
@elseif(auth()->user()->isPgAdmin())
|
||||||
|
@can('pg.guards.view')
|
||||||
<a href="{{ route('pg.dashboard') }}"
|
<a href="{{ route('pg.dashboard') }}"
|
||||||
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
@@ -172,32 +188,64 @@
|
|||||||
</svg>
|
</svg>
|
||||||
<span>Dashboard</span>
|
<span>Dashboard</span>
|
||||||
</a>
|
</a>
|
||||||
|
@endcan
|
||||||
@elseif(auth()->user()->isGateOfficer())
|
@elseif(auth()->user()->isGateOfficer())
|
||||||
|
@can('gate.inspect')
|
||||||
<a href="{{ route('pg.gate.inspection') }}"
|
<a href="{{ route('pg.gate.inspection') }}"
|
||||||
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
<i class="fa-solid fa-shield-halved text-base w-5 text-center"></i>
|
<i class="fa-solid fa-shield-halved text-base w-5 text-center"></i>
|
||||||
<span>Verifikasi Pos Gerbang</span>
|
<span>Verifikasi Pos Gerbang</span>
|
||||||
</a>
|
</a>
|
||||||
|
@endcan
|
||||||
@endif
|
@endif
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Grup: Modul Operasional RKM -->
|
@if(auth()->user()->isSuperAdmin())
|
||||||
@if(!auth()->user()->isGateOfficer())
|
|
||||||
<div>
|
<div>
|
||||||
<p class="px-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
|
<p class="px-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
|
||||||
MANAJEMEN SISTEM
|
SUPER ADMIN & RBAC
|
||||||
</p>
|
</p>
|
||||||
<nav class="space-y-1">
|
<nav class="space-y-1">
|
||||||
@if(auth()->user()->isHseAdmin() || auth()->user()->isAdmin())
|
<a href="{{ route('admin.users.index') }}"
|
||||||
<a href="{{ route('hse.employees.index') }}"
|
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('admin.users.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('hse.employees.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
<i class="fa-solid fa-users-gear text-base w-5 text-center"></i>
|
||||||
<i class="fa-solid fa-id-card text-base w-5 text-center"></i>
|
<span>Kelola Pengguna</span>
|
||||||
<span>Data Simper</span>
|
</a>
|
||||||
</a>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@if(auth()->user()->isQmaAdmin() || auth()->user()->isAdmin())
|
<a href="{{ route('admin.roles.index') }}"
|
||||||
|
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('admin.roles.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
|
<i class="fa-solid fa-shield-halved text-base w-5 text-center"></i>
|
||||||
|
<span>Role & Permission</span>
|
||||||
|
</a>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Grup: Manajemen HSE -->
|
||||||
|
@can('hse.employees.view')
|
||||||
|
<div>
|
||||||
|
<p class="px-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
|
||||||
|
MANAJEMEN HSE
|
||||||
|
</p>
|
||||||
|
<nav class="space-y-1">
|
||||||
|
<a href="{{ route('hse.employees.index') }}"
|
||||||
|
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('hse.employees.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
|
<i class="fa-solid fa-id-card text-base w-5 text-center"></i>
|
||||||
|
<span>Data Simper</span>
|
||||||
|
</a>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
@endcan
|
||||||
|
|
||||||
|
<!-- Grup: Manajemen QMA -->
|
||||||
|
@if(auth()->user()->canAny(['qma.vehicles.view', 'qma.logs.view', 'qma.summary.view']))
|
||||||
|
<div>
|
||||||
|
<p class="px-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
|
||||||
|
MANAJEMEN QMA
|
||||||
|
</p>
|
||||||
|
<nav class="space-y-1">
|
||||||
|
@can('qma.vehicles.view')
|
||||||
@php
|
@php
|
||||||
$isVehicleRoute = request()->routeIs('qma.vehicles.*');
|
$isVehicleRoute = request()->routeIs('qma.vehicles.*');
|
||||||
@endphp
|
@endphp
|
||||||
@@ -226,32 +274,58 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@endcan
|
||||||
|
|
||||||
|
@can('qma.logs.view')
|
||||||
<a href="{{ route('qma.activity.log') }}"
|
<a href="{{ route('qma.activity.log') }}"
|
||||||
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('qma.activity.log') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('qma.activity.log') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
<i class="fa-solid fa-clipboard-list text-base w-5 text-center"></i>
|
<i class="fa-solid fa-clipboard-list text-base w-5 text-center"></i>
|
||||||
<span>Log Aktivitas Kendaraan</span>
|
<span>Log Aktivitas Kendaraan</span>
|
||||||
</a>
|
</a>
|
||||||
|
@endcan
|
||||||
|
|
||||||
|
@can('qma.summary.view')
|
||||||
<a href="{{ route('qma.activity.summary') }}"
|
<a href="{{ route('qma.activity.summary') }}"
|
||||||
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('qma.activity.summary') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('qma.activity.summary') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
<i class="fa-solid fa-chart-pie text-base w-5 text-center"></i>
|
<i class="fa-solid fa-chart-pie text-base w-5 text-center"></i>
|
||||||
<span>Summary Aktivitas</span>
|
<span>Summary Aktivitas</span>
|
||||||
</a>
|
</a>
|
||||||
@endif
|
@endcan
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
@if(auth()->user()->isPgAdmin() || auth()->user()->isAdmin())
|
<!-- Grup: Manajemen Private Guard (PG) -->
|
||||||
|
@if(auth()->user()->canAny(['pg.guards.view', 'pg.logs.view', 'gate.inspect']))
|
||||||
|
<div>
|
||||||
|
<p class="px-3 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
|
||||||
|
MANAJEMEN PRIVATE GUARD (PG)
|
||||||
|
</p>
|
||||||
|
<nav class="space-y-1">
|
||||||
|
@can('pg.guards.view')
|
||||||
<a href="{{ route('pg.guards.index') }}"
|
<a href="{{ route('pg.guards.index') }}"
|
||||||
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.guards.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.guards.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
<i class="fa-solid fa-user-shield text-base w-5 text-center"></i>
|
<i class="fa-solid fa-user-shield text-base w-5 text-center"></i>
|
||||||
<span>Data Satpam</span>
|
<span>Data Satpam</span>
|
||||||
</a>
|
</a>
|
||||||
|
@endcan
|
||||||
|
|
||||||
|
@can('pg.logs.view')
|
||||||
<a href="{{ route('pg.logs.index') }}"
|
<a href="{{ route('pg.logs.index') }}"
|
||||||
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.logs.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.logs.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
<i class="fa-solid fa-clock-rotate-left text-base w-5 text-center"></i>
|
<i class="fa-solid fa-clock-rotate-left text-base w-5 text-center"></i>
|
||||||
<span>Log Verifikasi Gerbang</span>
|
<span>Log Verifikasi Gerbang</span>
|
||||||
</a>
|
</a>
|
||||||
|
@endcan
|
||||||
|
|
||||||
|
@if(!auth()->user()->isGateOfficer())
|
||||||
|
@can('gate.inspect')
|
||||||
|
<a href="{{ route('pg.gate.inspection') }}"
|
||||||
|
class="flex items-center space-x-3 px-3.5 py-2.5 text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
|
<i class="fa-solid fa-shield-halved text-base w-5 text-center"></i>
|
||||||
|
<span>Verifikasi Pos Gerbang</span>
|
||||||
|
</a>
|
||||||
|
@endcan
|
||||||
@endif
|
@endif
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
@@ -312,97 +386,181 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="p-4 space-y-4 flex-1 overflow-y-auto">
|
<div class="p-4 space-y-4 flex-1 overflow-y-auto">
|
||||||
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-wider px-2">NAVIGASI</p>
|
<div>
|
||||||
<div class="space-y-1">
|
<nav class="space-y-1">
|
||||||
@if(auth()->user()->isHseAdmin() || auth()->user()->isAdmin())
|
@if(auth()->user()->isSuperAdmin())
|
||||||
<a href="{{ route('hse.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('hse.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
<a href="{{ route('admin.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('admin.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
|
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
|
||||||
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
|
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
|
||||||
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
|
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
|
||||||
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
|
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
|
||||||
</svg>
|
</svg>
|
||||||
<span>Dashboard</span>
|
<span>Dashboard Admin</span>
|
||||||
|
</a>
|
||||||
|
@elseif(auth()->user()->isHseAdmin())
|
||||||
|
@can('hse.employees.view')
|
||||||
|
<a href="{{ route('hse.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('hse.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
|
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
|
||||||
|
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
|
||||||
|
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
|
||||||
|
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
|
||||||
|
</svg>
|
||||||
|
<span>Dashboard</span>
|
||||||
|
</a>
|
||||||
|
@endcan
|
||||||
|
@elseif(auth()->user()->isQmaAdmin())
|
||||||
|
@can('qma.vehicles.view')
|
||||||
|
<a href="{{ route('qma.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('qma.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
|
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
|
||||||
|
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
|
||||||
|
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
|
||||||
|
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
|
||||||
|
</svg>
|
||||||
|
<span>Dashboard</span>
|
||||||
|
</a>
|
||||||
|
@endcan
|
||||||
|
@elseif(auth()->user()->isPgAdmin())
|
||||||
|
@can('pg.guards.view')
|
||||||
|
<a href="{{ route('pg.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
|
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
|
||||||
|
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
|
||||||
|
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
|
||||||
|
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
|
||||||
|
</svg>
|
||||||
|
<span>Dashboard</span>
|
||||||
|
</a>
|
||||||
|
@endcan
|
||||||
|
@elseif(auth()->user()->isGateOfficer())
|
||||||
|
@can('gate.inspect')
|
||||||
|
<a href="{{ route('pg.gate.inspection') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
|
<i class="fa-solid fa-shield-halved text-base w-5 text-center"></i>
|
||||||
|
<span>Verifikasi Pos Gerbang</span>
|
||||||
|
</a>
|
||||||
|
@endcan
|
||||||
|
@endif
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if(auth()->user()->isSuperAdmin())
|
||||||
|
<div>
|
||||||
|
<p class="px-2 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
|
||||||
|
SUPER ADMIN & RBAC
|
||||||
|
</p>
|
||||||
|
<nav class="space-y-1">
|
||||||
|
<a href="{{ route('admin.users.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('admin.users.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
|
<i class="fa-solid fa-users-gear w-5 text-center"></i>
|
||||||
|
<span>Kelola Pengguna</span>
|
||||||
</a>
|
</a>
|
||||||
|
<a href="{{ route('admin.roles.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('admin.roles.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
|
<i class="fa-solid fa-shield-halved w-5 text-center"></i>
|
||||||
|
<span>Role & Permission</span>
|
||||||
|
</a>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Grup: Manajemen HSE -->
|
||||||
|
@can('hse.employees.view')
|
||||||
|
<div>
|
||||||
|
<p class="px-2 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
|
||||||
|
MANAJEMEN HSE
|
||||||
|
</p>
|
||||||
|
<nav class="space-y-1">
|
||||||
<a href="{{ route('hse.employees.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('hse.employees.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
<a href="{{ route('hse.employees.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('hse.employees.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
<i class="fa-solid fa-id-card w-5 text-center"></i>
|
<i class="fa-solid fa-id-card w-5 text-center"></i>
|
||||||
<span>Data Simper</span>
|
<span>Data Simper</span>
|
||||||
</a>
|
</a>
|
||||||
@endif
|
</nav>
|
||||||
@if(auth()->user()->isQmaAdmin() || auth()->user()->isAdmin())
|
|
||||||
<a href="{{ route('qma.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('qma.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
|
||||||
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
|
||||||
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
|
|
||||||
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
|
|
||||||
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
|
|
||||||
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
|
|
||||||
</svg>
|
|
||||||
<span>Dashboard</span>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
@php
|
|
||||||
$isVehicleRouteMob = request()->routeIs('qma.vehicles.*');
|
|
||||||
@endphp
|
|
||||||
<div>
|
|
||||||
<button type="button"
|
|
||||||
onclick="toggleVehicleMenu('mobile')"
|
|
||||||
class="w-full flex items-center justify-between px-3 py-2.5 text-sm rounded-xl transition group {{ $isVehicleRouteMob ? 'bg-emerald-50/70 text-[#1b5e20] font-bold' : 'sidebar-item-inactive' }}">
|
|
||||||
<div class="flex items-center space-x-3">
|
|
||||||
<i class="fa-solid fa-car w-5 text-center {{ $isVehicleRouteMob ? 'text-[#1b5e20]' : '' }}"></i>
|
|
||||||
<span>Data Kendaraan</span>
|
|
||||||
</div>
|
|
||||||
<i id="vehicleChevronMobile" class="fa-solid fa-chevron-down text-[11px] transition-transform duration-200 {{ $isVehicleRouteMob ? 'rotate-180 text-[#1b5e20]' : 'text-slate-400 group-hover:text-slate-600' }}"></i>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div id="vehicleSubmenuMobile" class="{{ $isVehicleRouteMob ? '' : 'hidden' }} mt-1 pl-7 pr-1 space-y-1">
|
|
||||||
<a href="{{ route('qma.vehicles.lv') }}"
|
|
||||||
class="block px-3.5 py-2 text-xs rounded-xl transition {{ request()->routeIs('qma.vehicles.lv') ? 'bg-[#1b5e20] text-white font-bold shadow-sm' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100 font-medium' }}">
|
|
||||||
<span>Light Vehicle</span>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a href="{{ route('qma.vehicles.support') }}"
|
|
||||||
class="block px-3.5 py-2 text-xs rounded-xl transition {{ request()->routeIs('qma.vehicles.support') ? 'bg-[#1b5e20] text-white font-bold shadow-sm' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100 font-medium' }}">
|
|
||||||
<span>Unit Support</span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a href="{{ route('qma.activity.log') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('qma.activity.log') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
|
||||||
<i class="fa-solid fa-clipboard-list w-5 text-center"></i>
|
|
||||||
<span>Log Aktivitas Kendaraan</span>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a href="{{ route('qma.activity.summary') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('qma.activity.summary') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
|
||||||
<i class="fa-solid fa-chart-pie w-5 text-center"></i>
|
|
||||||
<span>Summary Aktivitas</span>
|
|
||||||
</a>
|
|
||||||
@endif
|
|
||||||
@if(auth()->user()->isPgAdmin() || auth()->user()->isAdmin())
|
|
||||||
<a href="{{ route('pg.dashboard') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.dashboard') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
|
||||||
<svg class="w-5 h-5 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
|
||||||
<rect x="3" y="3" width="7" height="7" rx="2"></rect>
|
|
||||||
<rect x="14" y="3" width="7" height="7" rx="2"></rect>
|
|
||||||
<rect x="14" y="14" width="7" height="7" rx="2"></rect>
|
|
||||||
<rect x="3" y="14" width="7" height="7" rx="2"></rect>
|
|
||||||
</svg>
|
|
||||||
<span>Dashboard</span>
|
|
||||||
</a>
|
|
||||||
<a href="{{ route('pg.guards.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.guards.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
|
||||||
<i class="fa-solid fa-user-shield w-5 text-center"></i>
|
|
||||||
<span>Data Satpam</span>
|
|
||||||
</a>
|
|
||||||
<a href="{{ route('pg.logs.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.logs.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
|
||||||
<i class="fa-solid fa-clock-rotate-left w-5 text-center"></i>
|
|
||||||
<span>Log Verifikasi Gerbang</span>
|
|
||||||
</a>
|
|
||||||
@endif
|
|
||||||
@if(auth()->user()->isGateOfficer())
|
|
||||||
<a href="{{ route('pg.gate.inspection') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
|
||||||
<i class="fa-solid fa-shield-halved w-5 text-center"></i>
|
|
||||||
<span>Verifikasi Pos Gerbang</span>
|
|
||||||
</a>
|
|
||||||
@endif
|
|
||||||
</div>
|
</div>
|
||||||
|
@endcan
|
||||||
|
|
||||||
|
<!-- Grup: Manajemen QMA -->
|
||||||
|
@if(auth()->user()->canAny(['qma.vehicles.view', 'qma.logs.view', 'qma.summary.view']))
|
||||||
|
<div>
|
||||||
|
<p class="px-2 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
|
||||||
|
MANAJEMEN QMA
|
||||||
|
</p>
|
||||||
|
<nav class="space-y-1">
|
||||||
|
@can('qma.vehicles.view')
|
||||||
|
@php
|
||||||
|
$isVehicleRouteMob = request()->routeIs('qma.vehicles.*');
|
||||||
|
@endphp
|
||||||
|
<div>
|
||||||
|
<button type="button"
|
||||||
|
onclick="toggleVehicleMenu('mobile')"
|
||||||
|
class="w-full flex items-center justify-between px-3 py-2.5 text-sm rounded-xl transition group {{ $isVehicleRouteMob ? 'bg-emerald-50/70 text-[#1b5e20] font-bold' : 'sidebar-item-inactive' }}">
|
||||||
|
<div class="flex items-center space-x-3">
|
||||||
|
<i class="fa-solid fa-car w-5 text-center {{ $isVehicleRouteMob ? 'text-[#1b5e20]' : '' }}"></i>
|
||||||
|
<span>Data Kendaraan</span>
|
||||||
|
</div>
|
||||||
|
<i id="vehicleChevronMobile" class="fa-solid fa-chevron-down text-[11px] transition-transform duration-200 {{ $isVehicleRouteMob ? 'rotate-180 text-[#1b5e20]' : 'text-slate-400 group-hover:text-slate-600' }}"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div id="vehicleSubmenuMobile" class="{{ $isVehicleRouteMob ? '' : 'hidden' }} mt-1 pl-7 pr-1 space-y-1">
|
||||||
|
<a href="{{ route('qma.vehicles.lv') }}"
|
||||||
|
class="block px-3.5 py-2 text-xs rounded-xl transition {{ request()->routeIs('qma.vehicles.lv') ? 'bg-[#1b5e20] text-white font-bold shadow-sm' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100 font-medium' }}">
|
||||||
|
<span>Light Vehicle</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="{{ route('qma.vehicles.support') }}"
|
||||||
|
class="block px-3.5 py-2 text-xs rounded-xl transition {{ request()->routeIs('qma.vehicles.support') ? 'bg-[#1b5e20] text-white font-bold shadow-sm' : 'text-slate-600 hover:text-slate-900 hover:bg-slate-100 font-medium' }}">
|
||||||
|
<span>Unit Support</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endcan
|
||||||
|
|
||||||
|
@can('qma.logs.view')
|
||||||
|
<a href="{{ route('qma.activity.log') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('qma.activity.log') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
|
<i class="fa-solid fa-clipboard-list w-5 text-center"></i>
|
||||||
|
<span>Log Aktivitas Kendaraan</span>
|
||||||
|
</a>
|
||||||
|
@endcan
|
||||||
|
|
||||||
|
@can('qma.summary.view')
|
||||||
|
<a href="{{ route('qma.activity.summary') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('qma.activity.summary') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
|
<i class="fa-solid fa-chart-pie w-5 text-center"></i>
|
||||||
|
<span>Summary Aktivitas</span>
|
||||||
|
</a>
|
||||||
|
@endcan
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Grup: Manajemen Private Guard (PG) -->
|
||||||
|
@if(auth()->user()->canAny(['pg.guards.view', 'pg.logs.view', 'gate.inspect']))
|
||||||
|
<div>
|
||||||
|
<p class="px-2 text-[11px] font-bold text-slate-400 uppercase tracking-wider mb-2">
|
||||||
|
MANAJEMEN PRIVATE GUARD (PG)
|
||||||
|
</p>
|
||||||
|
<nav class="space-y-1">
|
||||||
|
@can('pg.guards.view')
|
||||||
|
<a href="{{ route('pg.guards.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.guards.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
|
<i class="fa-solid fa-user-shield w-5 text-center"></i>
|
||||||
|
<span>Data Satpam</span>
|
||||||
|
</a>
|
||||||
|
@endcan
|
||||||
|
@can('pg.logs.view')
|
||||||
|
<a href="{{ route('pg.logs.index') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.logs.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
|
<i class="fa-solid fa-clock-rotate-left w-5 text-center"></i>
|
||||||
|
<span>Log Verifikasi Gerbang</span>
|
||||||
|
</a>
|
||||||
|
@endcan
|
||||||
|
@if(!auth()->user()->isGateOfficer())
|
||||||
|
@can('gate.inspect')
|
||||||
|
<a href="{{ route('pg.gate.inspection') }}" class="flex items-center space-x-3 px-3 py-2.5 rounded-xl text-sm {{ request()->routeIs('pg.gate.*') ? 'sidebar-item-active' : 'sidebar-item-inactive' }}">
|
||||||
|
<i class="fa-solid fa-shield-halved w-5 text-center"></i>
|
||||||
|
<span>Verifikasi Pos Gerbang</span>
|
||||||
|
</a>
|
||||||
|
@endcan
|
||||||
|
@endif
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-wider px-2 mt-4">PENGATURAN</p>
|
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-wider px-2 mt-4">PENGATURAN</p>
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
|
|||||||
@@ -27,12 +27,14 @@
|
|||||||
|
|
||||||
<!-- Tombol Aksi Kanan (+ Tambah Satpam Hijau Tua) -->
|
<!-- Tombol Aksi Kanan (+ Tambah Satpam Hijau Tua) -->
|
||||||
<div class="flex items-center space-x-3 w-full sm:w-auto">
|
<div class="flex items-center space-x-3 w-full sm:w-auto">
|
||||||
|
@can('pg.guards.create')
|
||||||
<button type="button"
|
<button type="button"
|
||||||
onclick="document.getElementById('addGuardModal').classList.remove('hidden')"
|
onclick="document.getElementById('addGuardModal').classList.remove('hidden')"
|
||||||
class="w-full sm:w-auto bg-[#1b5e20] hover:bg-[#144919] text-white px-5 py-2.5 rounded-xl text-xs font-bold flex items-center justify-center space-x-2 transition shadow-sm">
|
class="w-full sm:w-auto bg-[#1b5e20] hover:bg-[#144919] text-white px-5 py-2.5 rounded-xl text-xs font-bold flex items-center justify-center space-x-2 transition shadow-sm">
|
||||||
<i class="fa-solid fa-plus text-xs"></i>
|
<i class="fa-solid fa-plus text-xs"></i>
|
||||||
<span>Tambah Petugas Satpam</span>
|
<span>Tambah Petugas Satpam</span>
|
||||||
</button>
|
</button>
|
||||||
|
@endcan
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -169,6 +171,7 @@
|
|||||||
<!-- Aksi (Ikon Edit Oranye & Ikon Status Merah Selaras Format Gambar) -->
|
<!-- Aksi (Ikon Edit Oranye & Ikon Status Merah Selaras Format Gambar) -->
|
||||||
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
||||||
<div class="flex items-center justify-center space-x-2">
|
<div class="flex items-center justify-center space-x-2">
|
||||||
|
@can('pg.guards.edit')
|
||||||
<!-- Tombol Edit Oranye -->
|
<!-- Tombol Edit Oranye -->
|
||||||
<button type="button"
|
<button type="button"
|
||||||
onclick="openEditGuardModal({{ json_encode($g) }})"
|
onclick="openEditGuardModal({{ json_encode($g) }})"
|
||||||
@@ -176,7 +179,9 @@
|
|||||||
title="Edit Data / Reset Password">
|
title="Edit Data / Reset Password">
|
||||||
<i class="fa-regular fa-pen-to-square text-sm"></i>
|
<i class="fa-regular fa-pen-to-square text-sm"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@endcan
|
||||||
|
|
||||||
|
@can('pg.guards.toggle')
|
||||||
<!-- Tombol Toggle Nonaktifkan/Aktifkan Merah/Hijau -->
|
<!-- Tombol Toggle Nonaktifkan/Aktifkan Merah/Hijau -->
|
||||||
<button type="button"
|
<button type="button"
|
||||||
onclick="openToggleStatusModal({{ $g->id }}, '{{ addslashes($g->name) }}', '{{ $g->badge_id ?? 'SEC-' . str_pad($g->id, 3, '0', STR_PAD_LEFT) }}', {{ $g->is_active ? 'true' : 'false' }})"
|
onclick="openToggleStatusModal({{ $g->id }}, '{{ addslashes($g->name) }}', '{{ $g->badge_id ?? 'SEC-' . str_pad($g->id, 3, '0', STR_PAD_LEFT) }}', {{ $g->is_active ? 'true' : 'false' }})"
|
||||||
@@ -184,7 +189,9 @@
|
|||||||
class="{{ $g->is_active ? 'text-rose-500 hover:text-rose-700' : 'text-emerald-600 hover:text-emerald-800' }} p-1.5 transition cursor-pointer">
|
class="{{ $g->is_active ? 'text-rose-500 hover:text-rose-700' : 'text-emerald-600 hover:text-emerald-800' }} p-1.5 transition cursor-pointer">
|
||||||
<i class="fa-solid fa-power-off text-sm"></i>
|
<i class="fa-solid fa-power-off text-sm"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@endcan
|
||||||
|
|
||||||
|
@can('pg.guards.delete')
|
||||||
<!-- Tombol Hapus Merah -->
|
<!-- Tombol Hapus Merah -->
|
||||||
<button type="button"
|
<button type="button"
|
||||||
onclick="openDeleteGuardModal({{ $g->id }}, '{{ addslashes($g->name) }}', '{{ $g->badge_id ?? 'SEC-' . str_pad($g->id, 3, '0', STR_PAD_LEFT) }}')"
|
onclick="openDeleteGuardModal({{ $g->id }}, '{{ addslashes($g->name) }}', '{{ $g->badge_id ?? 'SEC-' . str_pad($g->id, 3, '0', STR_PAD_LEFT) }}')"
|
||||||
@@ -192,6 +199,11 @@
|
|||||||
class="text-rose-600 hover:text-rose-800 p-1.5 transition cursor-pointer">
|
class="text-rose-600 hover:text-rose-800 p-1.5 transition cursor-pointer">
|
||||||
<i class="fa-regular fa-trash-can text-sm"></i>
|
<i class="fa-regular fa-trash-can text-sm"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@endcan
|
||||||
|
|
||||||
|
@if(!auth()->user()->can('pg.guards.edit') && !auth()->user()->can('pg.guards.toggle') && !auth()->user()->can('pg.guards.delete'))
|
||||||
|
<span class="text-xs text-slate-400 italic">Hanya lihat</span>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
<span>Cek fisik kendaraan lalu klik verifikasi untuk membuka portal</span>
|
<span>Cek fisik kendaraan lalu klik verifikasi untuk membuka portal</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
@can('gate.approve')
|
||||||
<form action="{{ route('pg.gate.approve', $act->id) }}" method="POST" class="w-full sm:w-auto m-0">
|
<form action="{{ route('pg.gate.approve', $act->id) }}" method="POST" class="w-full sm:w-auto m-0">
|
||||||
@csrf
|
@csrf
|
||||||
@if($currentGuard)
|
@if($currentGuard)
|
||||||
@@ -109,6 +110,9 @@
|
|||||||
<span>Verifikasi</span>
|
<span>Verifikasi</span>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
@else
|
||||||
|
<span class="text-xs text-slate-400 italic">Tidak memiliki izin verifikasi</span>
|
||||||
|
@endcan
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -35,11 +35,13 @@
|
|||||||
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-1"></i>
|
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-1"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
@can('qma.vehicles.create')
|
||||||
<button onclick="openAddModal()"
|
<button onclick="openAddModal()"
|
||||||
class="bg-[#1b5e20] hover:bg-[#144919] text-white px-4 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-sm">
|
class="bg-[#1b5e20] hover:bg-[#144919] text-white px-4 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-sm">
|
||||||
<i class="fa-solid fa-plus text-xs"></i>
|
<i class="fa-solid fa-plus text-xs"></i>
|
||||||
<span>Tambah Light Vehicle</span>
|
<span>Tambah Light Vehicle</span>
|
||||||
</button>
|
</button>
|
||||||
|
@endcan
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -182,17 +184,21 @@
|
|||||||
title="Lihat Detail Kendaraan">
|
title="Lihat Detail Kendaraan">
|
||||||
<i class="fa-regular fa-eye text-sm"></i>
|
<i class="fa-regular fa-eye text-sm"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@can('qma.vehicles.edit')
|
||||||
<button onclick='openEditModal(@json($v))'
|
<button onclick='openEditModal(@json($v))'
|
||||||
class="inline-flex items-center space-x-1 text-amber-600 hover:text-amber-800 hover:bg-amber-50 px-2 py-1 rounded-lg transition"
|
class="inline-flex items-center space-x-1 text-amber-600 hover:text-amber-800 hover:bg-amber-50 px-2 py-1 rounded-lg transition"
|
||||||
title="Edit Data Light Vehicle">
|
title="Edit Data Light Vehicle">
|
||||||
<i class="fa-regular fa-pen-to-square text-sm"></i>
|
<i class="fa-regular fa-pen-to-square text-sm"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@endcan
|
||||||
|
@can('qma.vehicles.delete')
|
||||||
<button type="button"
|
<button type="button"
|
||||||
onclick="openDeleteModal('{{ $v->id }}', '{{ $v->code }}', '{{ addslashes($v->brand_type ?? '') }}')"
|
onclick="openDeleteModal('{{ $v->id }}', '{{ $v->code }}', '{{ addslashes($v->brand_type ?? '') }}')"
|
||||||
class="inline-flex items-center space-x-1 text-rose-600 hover:text-rose-800 hover:bg-rose-50 px-2 py-1 rounded-lg transition"
|
class="inline-flex items-center space-x-1 text-rose-600 hover:text-rose-800 hover:bg-rose-50 px-2 py-1 rounded-lg transition"
|
||||||
title="Hapus Kendaraan">
|
title="Hapus Kendaraan">
|
||||||
<i class="fa-regular fa-trash-can text-sm"></i>
|
<i class="fa-regular fa-trash-can text-sm"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@endcan
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -35,11 +35,13 @@
|
|||||||
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-1"></i>
|
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-1"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
@can('qma.vehicles.create')
|
||||||
<button onclick="openAddModal()"
|
<button onclick="openAddModal()"
|
||||||
class="bg-[#1b5e20] hover:bg-[#144919] text-white px-4 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-sm">
|
class="bg-[#1b5e20] hover:bg-[#144919] text-white px-4 py-2.5 rounded-xl text-xs font-bold flex items-center space-x-2 transition shadow-sm">
|
||||||
<i class="fa-solid fa-plus text-xs"></i>
|
<i class="fa-solid fa-plus text-xs"></i>
|
||||||
<span>Tambah Unit Support</span>
|
<span>Tambah Unit Support</span>
|
||||||
</button>
|
</button>
|
||||||
|
@endcan
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -214,17 +216,21 @@
|
|||||||
title="Lihat Detail & Perizinan">
|
title="Lihat Detail & Perizinan">
|
||||||
<i class="fa-regular fa-eye text-sm"></i>
|
<i class="fa-regular fa-eye text-sm"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@can('qma.vehicles.edit')
|
||||||
<button onclick='openEditModal(@json($v))'
|
<button onclick='openEditModal(@json($v))'
|
||||||
class="inline-flex items-center space-x-1 text-amber-600 hover:text-amber-800 hover:bg-amber-50 px-2 py-1 rounded-lg transition"
|
class="inline-flex items-center space-x-1 text-amber-600 hover:text-amber-800 hover:bg-amber-50 px-2 py-1 rounded-lg transition"
|
||||||
title="Edit Data Unit Support">
|
title="Edit Data Unit Support">
|
||||||
<i class="fa-regular fa-pen-to-square text-sm"></i>
|
<i class="fa-regular fa-pen-to-square text-sm"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@endcan
|
||||||
|
@can('qma.vehicles.delete')
|
||||||
<button type="button"
|
<button type="button"
|
||||||
onclick="openDeleteModal('{{ $v->id }}', '{{ $v->code }}', '{{ addslashes($v->brand_type ?? '') }}')"
|
onclick="openDeleteModal('{{ $v->id }}', '{{ $v->code }}', '{{ addslashes($v->brand_type ?? '') }}')"
|
||||||
class="inline-flex items-center space-x-1 text-rose-600 hover:text-rose-800 hover:bg-rose-50 px-2 py-1 rounded-lg transition"
|
class="inline-flex items-center space-x-1 text-rose-600 hover:text-rose-800 hover:bg-rose-50 px-2 py-1 rounded-lg transition"
|
||||||
title="Hapus Unit">
|
title="Hapus Unit">
|
||||||
<i class="fa-regular fa-trash-can text-sm"></i>
|
<i class="fa-regular fa-trash-can text-sm"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@endcan
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
+48
-32
@@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Http\Controllers\Admin\DashboardController as AdminDashboardController;
|
||||||
|
use App\Http\Controllers\Admin\RolePermissionController;
|
||||||
|
use App\Http\Controllers\Admin\UserController;
|
||||||
use App\Http\Controllers\Auth\LoginController;
|
use App\Http\Controllers\Auth\LoginController;
|
||||||
use App\Http\Controllers\HomeController;
|
use App\Http\Controllers\HomeController;
|
||||||
use App\Http\Controllers\Hse\EmployeeController;
|
use App\Http\Controllers\Hse\EmployeeController;
|
||||||
@@ -35,53 +38,66 @@ Route::prefix('gate-activity')->name('vehicle.activity.')->group(function () {
|
|||||||
// Group Terproteksi Autentikasi Sistem
|
// Group Terproteksi Autentikasi Sistem
|
||||||
Route::middleware('auth')->group(function () {
|
Route::middleware('auth')->group(function () {
|
||||||
|
|
||||||
// 2. Modul HSE: Admin HSE (Mima - 1185) - Kelola Karyawan & SIMPER
|
// 2. Modul HSE: Admin HSE - Kelola Karyawan & SIMPER
|
||||||
Route::prefix('hse')->name('hse.')->middleware('role:hse_admin')->group(function () {
|
Route::prefix('hse')->name('hse.')->group(function () {
|
||||||
Route::get('/dashboard', [EmployeeController::class, 'dashboard'])->name('dashboard');
|
Route::get('/dashboard', [EmployeeController::class, 'dashboard'])->name('dashboard')->middleware('permission:hse.employees.view');
|
||||||
Route::get('/employees', [EmployeeController::class, 'index'])->name('employees.index');
|
Route::get('/employees', [EmployeeController::class, 'index'])->name('employees.index')->middleware('permission:hse.employees.view');
|
||||||
Route::post('/employees', [EmployeeController::class, 'store'])->name('employees.store');
|
Route::post('/employees', [EmployeeController::class, 'store'])->name('employees.store')->middleware('permission:hse.employees.create');
|
||||||
Route::post('/employees/{id}', [EmployeeController::class, 'update'])->name('employees.update');
|
Route::post('/employees/{id}', [EmployeeController::class, 'update'])->name('employees.update')->middleware('permission:hse.employees.edit');
|
||||||
});
|
});
|
||||||
|
|
||||||
// 3. Modul QMA: Admin QMA (Pinto Yuliandra - 1171) - Dashboard, Data Kendaraan & Log Aktivitas
|
// 3. Modul QMA: Admin QMA - Dashboard, Data Kendaraan & Log Aktivitas
|
||||||
Route::prefix('qma')->name('qma.')->middleware('role:qma_admin')->group(function () {
|
Route::prefix('qma')->name('qma.')->group(function () {
|
||||||
Route::get('/dashboard', [VehicleController::class, 'dashboard'])->name('dashboard');
|
Route::get('/dashboard', [VehicleController::class, 'dashboard'])->name('dashboard')->middleware('permission:qma.vehicles.view');
|
||||||
|
|
||||||
// Halaman Data Kendaraan Terpisah: Light Vehicle (LV) dan Unit Support
|
// Halaman Data Kendaraan Terpisah: Light Vehicle (LV) dan Unit Support
|
||||||
Route::get('/vehicles', [VehicleController::class, 'index'])->name('vehicles.index');
|
Route::get('/vehicles', [VehicleController::class, 'index'])->name('vehicles.index')->middleware('permission:qma.vehicles.view');
|
||||||
Route::get('/vehicles/light-vehicle', [VehicleController::class, 'indexLv'])->name('vehicles.lv');
|
Route::get('/vehicles/light-vehicle', [VehicleController::class, 'indexLv'])->name('vehicles.lv')->middleware('permission:qma.vehicles.view');
|
||||||
Route::get('/vehicles/unit-support', [VehicleController::class, 'indexSupport'])->name('vehicles.support');
|
Route::get('/vehicles/unit-support', [VehicleController::class, 'indexSupport'])->name('vehicles.support')->middleware('permission:qma.vehicles.view');
|
||||||
|
|
||||||
Route::post('/vehicles', [VehicleController::class, 'store'])->name('vehicles.store');
|
Route::post('/vehicles', [VehicleController::class, 'store'])->name('vehicles.store')->middleware('permission:qma.vehicles.create');
|
||||||
Route::post('/vehicles/{id}', [VehicleController::class, 'update'])->name('vehicles.update');
|
Route::post('/vehicles/{id}', [VehicleController::class, 'update'])->name('vehicles.update')->middleware('permission:qma.vehicles.edit');
|
||||||
Route::delete('/vehicles/{id}', [VehicleController::class, 'destroy'])->name('vehicles.destroy');
|
Route::delete('/vehicles/{id}', [VehicleController::class, 'destroy'])->name('vehicles.destroy')->middleware('permission:qma.vehicles.delete');
|
||||||
Route::get('/activity-log', [ActivityLogController::class, 'index'])->name('activity.log');
|
Route::get('/activity-log', [ActivityLogController::class, 'index'])->name('activity.log')->middleware('permission:qma.logs.view');
|
||||||
Route::get('/activity-summary', [ActivityLogController::class, 'summary'])->name('activity.summary');
|
Route::get('/activity-summary', [ActivityLogController::class, 'summary'])->name('activity.summary')->middleware('permission:qma.summary.view');
|
||||||
});
|
});
|
||||||
|
|
||||||
// 4. Modul Private Guard (PG): Admin PG & Pos Gerbang Satpam
|
// 4. Modul Private Guard (PG): Admin PG & Pos Gerbang Satpam
|
||||||
Route::prefix('pg')->name('pg.')->group(function () {
|
Route::prefix('pg')->name('pg.')->group(function () {
|
||||||
// Modul Admin PG (Dashboard, Data Satpam & Log Verifikasi Gerbang)
|
// Modul Admin PG (Dashboard, Data Satpam & Log Verifikasi Gerbang)
|
||||||
Route::middleware('role:pg_admin')->group(function () {
|
Route::get('/dashboard', [PgDashboardController::class, 'index'])->name('dashboard')->middleware('permission:pg.guards.view');
|
||||||
Route::get('/dashboard', [PgDashboardController::class, 'index'])->name('dashboard');
|
Route::get('/guards', [SecurityGuardController::class, 'index'])->name('guards.index')->middleware('permission:pg.guards.view');
|
||||||
Route::get('/guards', [SecurityGuardController::class, 'index'])->name('guards.index');
|
Route::post('/guards', [SecurityGuardController::class, 'store'])->name('guards.store')->middleware('permission:pg.guards.create');
|
||||||
Route::post('/guards', [SecurityGuardController::class, 'store'])->name('guards.store');
|
Route::post('/guards/{id}', [SecurityGuardController::class, 'update'])->name('guards.update')->middleware('permission:pg.guards.edit');
|
||||||
Route::post('/guards/{id}', [SecurityGuardController::class, 'update'])->name('guards.update');
|
Route::post('/guards/{id}/toggle', [SecurityGuardController::class, 'toggleStatus'])->name('guards.toggle')->middleware('permission:pg.guards.toggle');
|
||||||
Route::post('/guards/{id}/toggle', [SecurityGuardController::class, 'toggleStatus'])->name('guards.toggle');
|
Route::delete('/guards/{id}', [SecurityGuardController::class, 'destroy'])->name('guards.destroy')->middleware('permission:pg.guards.delete');
|
||||||
Route::delete('/guards/{id}', [SecurityGuardController::class, 'destroy'])->name('guards.destroy');
|
Route::get('/verification-logs', [VerificationLogController::class, 'index'])->name('logs.index')->middleware('permission:pg.logs.view');
|
||||||
Route::get('/verification-logs', [VerificationLogController::class, 'index'])->name('logs.index');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Verifikasi Pos Gerbang (Khusus Petugas Satpam Pos Gerbang)
|
// Verifikasi Pos Gerbang (Khusus Petugas Satpam Pos Gerbang)
|
||||||
Route::middleware('role:gate_officer')->group(function () {
|
Route::get('/gate-inspection', [GateInspectionController::class, 'index'])->name('gate.inspection')->middleware('permission:gate.inspect');
|
||||||
Route::get('/gate-inspection', [GateInspectionController::class, 'index'])->name('gate.inspection');
|
Route::get('/gate-inspection/live-queue', [GateInspectionController::class, 'liveQueue'])->name('gate.live_queue')->middleware('permission:gate.inspect');
|
||||||
Route::get('/gate-inspection/live-queue', [GateInspectionController::class, 'liveQueue'])->name('gate.live_queue');
|
Route::post('/gate-inspection/{id}/approve', [GateInspectionController::class, 'approve'])->name('gate.approve')->middleware('permission:gate.approve');
|
||||||
Route::post('/gate-inspection/{id}/approve', [GateInspectionController::class, 'approve'])->name('gate.approve');
|
Route::post('/gate-inspection/{id}/reject', [GateInspectionController::class, 'reject'])->name('gate.reject')->middleware('permission:gate.reject');
|
||||||
Route::post('/gate-inspection/{id}/reject', [GateInspectionController::class, 'reject'])->name('gate.reject');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 5. Modul Profil Saya (Seluruh Pengguna Terautentikasi)
|
// 5. Modul Profil Saya (Seluruh Pengguna Terautentikasi)
|
||||||
Route::get('/profile', [ProfileController::class, 'index'])->name('profile.index');
|
Route::get('/profile', [ProfileController::class, 'index'])->name('profile.index');
|
||||||
Route::put('/profile', [ProfileController::class, 'update'])->name('profile.update');
|
Route::put('/profile', [ProfileController::class, 'update'])->name('profile.update');
|
||||||
|
|
||||||
|
// 6. Modul Super Admin (RBAC, Manajemen Pengguna & Hak Akses)
|
||||||
|
Route::prefix('admin')->name('admin.')->middleware('role:super_admin')->group(function () {
|
||||||
|
Route::get('/dashboard', [AdminDashboardController::class, 'index'])->name('dashboard');
|
||||||
|
|
||||||
|
// Manajemen User
|
||||||
|
Route::get('/users', [UserController::class, 'index'])->name('users.index')->middleware('permission:users.view');
|
||||||
|
Route::post('/users', [UserController::class, 'store'])->name('users.store')->middleware('permission:users.create');
|
||||||
|
Route::post('/users/{id}', [UserController::class, 'update'])->name('users.update')->middleware('permission:users.edit');
|
||||||
|
Route::delete('/users/{id}', [UserController::class, 'destroy'])->name('users.destroy')->middleware('permission:users.delete');
|
||||||
|
|
||||||
|
// Manajemen Roles & Permissions (RBAC Matrix)
|
||||||
|
Route::get('/roles', [RolePermissionController::class, 'index'])->name('roles.index')->middleware('permission:roles.view');
|
||||||
|
Route::post('/roles', [RolePermissionController::class, 'storeRole'])->name('roles.store')->middleware('permission:roles.create');
|
||||||
|
Route::post('/roles/{id}/permissions', [RolePermissionController::class, 'updatePermissions'])->name('roles.permissions.update')->middleware('permission:roles.edit_permissions');
|
||||||
|
Route::delete('/roles/{id}', [RolePermissionController::class, 'destroyRole'])->name('roles.destroy')->middleware('permission:roles.delete');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,287 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Gate;
|
||||||
|
use App\Models\User;
|
||||||
|
use Database\Seeders\RolePermissionSeeder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class SuperAdminRbacTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
// Pastikan role dan permissions ada
|
||||||
|
$this->seed(RolePermissionSeeder::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_super_admin_can_login_and_redirects_to_admin_dashboard(): void
|
||||||
|
{
|
||||||
|
$response = $this->post(route('login.post'), [
|
||||||
|
'username' => 'superadmin',
|
||||||
|
'password' => 'password',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertRedirect(route('admin.dashboard'));
|
||||||
|
$this->assertAuthenticated();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_super_admin_can_view_dashboard_and_modules(): void
|
||||||
|
{
|
||||||
|
$superAdmin = User::where('username', 'superadmin')->first();
|
||||||
|
|
||||||
|
$response = $this->actingAs($superAdmin)->get(route('admin.dashboard'));
|
||||||
|
$response->assertOk();
|
||||||
|
$response->assertSee('Dashboard Super Admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_non_super_admin_cannot_access_admin_dashboard(): void
|
||||||
|
{
|
||||||
|
$regularUser = User::factory()->create([
|
||||||
|
'role' => 'hse_admin',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = $this->actingAs($regularUser)->get(route('admin.dashboard'));
|
||||||
|
$response->assertForbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_super_admin_can_view_users_page(): void
|
||||||
|
{
|
||||||
|
$superAdmin = User::where('username', 'superadmin')->first();
|
||||||
|
|
||||||
|
$response = $this->actingAs($superAdmin)->get(route('admin.users.index'));
|
||||||
|
$response->assertOk();
|
||||||
|
$response->assertSee('Manajemen Pengguna Sistem');
|
||||||
|
$response->assertSee('superadmin');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_super_admin_can_create_new_user_with_spatie_role(): void
|
||||||
|
{
|
||||||
|
$superAdmin = User::where('username', 'superadmin')->first();
|
||||||
|
|
||||||
|
$response = $this->actingAs($superAdmin)->post(route('admin.users.store'), [
|
||||||
|
'name' => 'Operator Baru',
|
||||||
|
'username' => 'operator.baru',
|
||||||
|
'email' => '[email protected]',
|
||||||
|
'password' => 'password123',
|
||||||
|
'role' => 'gate_officer',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertRedirect(route('admin.users.index'));
|
||||||
|
$response->assertSessionHas('success');
|
||||||
|
|
||||||
|
$newUser = User::where('username', 'operator.baru')->first();
|
||||||
|
$this->assertNotNull($newUser);
|
||||||
|
$this->assertTrue($newUser->hasRole('gate_officer'));
|
||||||
|
$this->assertEquals('gate_officer', $newUser->role);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_super_admin_can_update_user_and_change_role(): void
|
||||||
|
{
|
||||||
|
$superAdmin = User::where('username', 'superadmin')->first();
|
||||||
|
$user = User::factory()->create([
|
||||||
|
'name' => 'Pinto Yuliandra',
|
||||||
|
'username' => '1171',
|
||||||
|
'email' => '[email protected]',
|
||||||
|
'role' => 'qma_admin',
|
||||||
|
]);
|
||||||
|
$user->assignRole('qma_admin');
|
||||||
|
|
||||||
|
$response = $this->actingAs($superAdmin)->post(route('admin.users.update', $user->id), [
|
||||||
|
'name' => 'Pinto Yuliandra Updated',
|
||||||
|
'username' => '1171',
|
||||||
|
'email' => '[email protected]',
|
||||||
|
'role' => 'hse_admin',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertRedirect(route('admin.users.index'));
|
||||||
|
|
||||||
|
$user->refresh();
|
||||||
|
$this->assertEquals('Pinto Yuliandra Updated', $user->name);
|
||||||
|
$this->assertTrue($user->hasRole('hse_admin'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_super_admin_cannot_delete_own_account_or_main_superadmin(): void
|
||||||
|
{
|
||||||
|
$superAdmin = User::where('username', 'superadmin')->first();
|
||||||
|
|
||||||
|
$response = $this->actingAs($superAdmin)->delete(route('admin.users.destroy', $superAdmin->id));
|
||||||
|
$response->assertRedirect(route('admin.users.index'));
|
||||||
|
$response->assertSessionHas('error');
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('users', ['id' => $superAdmin->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_super_admin_can_view_and_update_role_permissions(): void
|
||||||
|
{
|
||||||
|
$superAdmin = User::where('username', 'superadmin')->first();
|
||||||
|
$role = Role::findByName('hse_admin');
|
||||||
|
|
||||||
|
$response = $this->actingAs($superAdmin)->get(route('admin.roles.index'));
|
||||||
|
$response->assertOk();
|
||||||
|
$response->assertSee('Matriks Role');
|
||||||
|
|
||||||
|
// Update permissions for hse_admin
|
||||||
|
$response = $this->actingAs($superAdmin)->post(route('admin.roles.permissions.update', $role->id), [
|
||||||
|
'permissions' => ['hse.employees.view'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertRedirect(route('admin.roles.index'));
|
||||||
|
$response->assertSessionHas('success');
|
||||||
|
|
||||||
|
$role->refresh();
|
||||||
|
$this->assertTrue($role->hasPermissionTo('hse.employees.view'));
|
||||||
|
$this->assertFalse($role->hasPermissionTo('hse.employees.create'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_super_admin_can_assign_direct_permissions_to_user(): void
|
||||||
|
{
|
||||||
|
$superAdmin = User::where('username', 'superadmin')->first();
|
||||||
|
$user = User::factory()->create([
|
||||||
|
'role' => 'gate_officer',
|
||||||
|
]);
|
||||||
|
$user->assignRole('gate_officer');
|
||||||
|
|
||||||
|
$response = $this->actingAs($superAdmin)->post(route('admin.users.update', $user->id), [
|
||||||
|
'name' => $user->name,
|
||||||
|
'username' => $user->username,
|
||||||
|
'email' => $user->email,
|
||||||
|
'role' => 'gate_officer',
|
||||||
|
'direct_permissions' => ['qma.logs.view'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertRedirect(route('admin.users.index'));
|
||||||
|
|
||||||
|
$user->refresh();
|
||||||
|
$this->assertTrue($user->hasDirectPermission('qma.logs.view'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_super_admin_has_bypass_access_to_all_modules(): void
|
||||||
|
{
|
||||||
|
$superAdmin = User::where('username', 'superadmin')->first();
|
||||||
|
|
||||||
|
// HSE Dashboard
|
||||||
|
$response = $this->actingAs($superAdmin)->get(route('hse.dashboard'));
|
||||||
|
$response->assertOk();
|
||||||
|
|
||||||
|
// QMA Dashboard
|
||||||
|
$response = $this->actingAs($superAdmin)->get(route('qma.dashboard'));
|
||||||
|
$response->assertOk();
|
||||||
|
|
||||||
|
// PG Dashboard
|
||||||
|
$response = $this->actingAs($superAdmin)->get(route('pg.dashboard'));
|
||||||
|
$response->assertOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_permission_revocation_immediately_blocks_action_and_hides_button(): void
|
||||||
|
{
|
||||||
|
$superAdmin = User::where('username', 'superadmin')->first();
|
||||||
|
$hseUser = User::factory()->create([
|
||||||
|
'role' => 'hse_admin',
|
||||||
|
]);
|
||||||
|
$hseUser->assignRole('hse_admin');
|
||||||
|
|
||||||
|
// 1. Sebelum izin dicabut: bisa melihat tombol dan menambah karyawan
|
||||||
|
$resView = $this->actingAs($hseUser)->get(route('hse.employees.index'));
|
||||||
|
$resView->assertOk();
|
||||||
|
$resView->assertSee('Tambah Karyawan');
|
||||||
|
|
||||||
|
$resStore = $this->actingAs($hseUser)->post(route('hse.employees.store'), [
|
||||||
|
'nik' => 'NIK-TEST-001',
|
||||||
|
'name' => 'Budi Santoso',
|
||||||
|
'unit_kerja' => 'Teknik',
|
||||||
|
'division' => 'Civil',
|
||||||
|
'position' => 'Driver',
|
||||||
|
'is_operator' => '1',
|
||||||
|
'simper_expired_at' => now()->addYear()->format('Y-m-d'),
|
||||||
|
]);
|
||||||
|
$resStore->assertRedirect();
|
||||||
|
$this->assertDatabaseHas('employees', ['nik' => 'NIK-TEST-001']);
|
||||||
|
|
||||||
|
// 2. Super Admin mencabut izin 'hse.employees.create' dari role hse_admin
|
||||||
|
$role = Role::findByName('hse_admin');
|
||||||
|
$this->actingAs($superAdmin)->post(route('admin.roles.permissions.update', $role->id), [
|
||||||
|
'permissions' => ['hse.employees.view'], // hse.employees.create sengaja dicabut
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 3. Verifikasi Sinkronisasi Langsung:
|
||||||
|
// A. Tombol 'Tambah Karyawan' langsung hilang dari halaman index
|
||||||
|
$resViewRevoked = $this->actingAs($hseUser)->get(route('hse.employees.index'));
|
||||||
|
$resViewRevoked->assertOk();
|
||||||
|
$resViewRevoked->assertDontSee('<span>Tambah Karyawan</span>', false);
|
||||||
|
|
||||||
|
// B. Akses request POST langsung diblokir 403 Forbidden
|
||||||
|
$resStoreBlocked = $this->actingAs($hseUser)->post(route('hse.employees.store'), [
|
||||||
|
'nik' => 'NIK-TEST-002',
|
||||||
|
'name' => 'Karyawan Baru',
|
||||||
|
'unit_kerja' => 'Teknik',
|
||||||
|
'division' => 'Civil',
|
||||||
|
'position' => 'Driver',
|
||||||
|
'is_operator' => '1',
|
||||||
|
]);
|
||||||
|
$resStoreBlocked->assertForbidden();
|
||||||
|
$this->assertDatabaseMissing('employees', ['nik' => 'NIK-TEST-002']);
|
||||||
|
|
||||||
|
// 4. Super Admin mengembalikan izin 'hse.employees.create'
|
||||||
|
$this->actingAs($superAdmin)->post(route('admin.roles.permissions.update', $role->id), [
|
||||||
|
'permissions' => ['hse.employees.view', 'hse.employees.create', 'hse.employees.edit'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 5. User langsung bisa menambah karyawan kembali
|
||||||
|
$resStoreRestored = $this->actingAs($hseUser)->post(route('hse.employees.store'), [
|
||||||
|
'nik' => 'NIK-TEST-002',
|
||||||
|
'name' => 'Karyawan Baru',
|
||||||
|
'unit_kerja' => 'Teknik',
|
||||||
|
'division' => 'Civil',
|
||||||
|
'position' => 'Driver',
|
||||||
|
'is_operator' => '1',
|
||||||
|
]);
|
||||||
|
$resStoreRestored->assertRedirect();
|
||||||
|
$this->assertDatabaseHas('employees', ['nik' => 'NIK-TEST-002']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_user_direct_permission_sync_allows_or_denies_immediately(): void
|
||||||
|
{
|
||||||
|
$superAdmin = User::where('username', 'superadmin')->first();
|
||||||
|
$gateUser = User::factory()->create([
|
||||||
|
'role' => 'gate_officer',
|
||||||
|
]);
|
||||||
|
$gateUser->assignRole('gate_officer');
|
||||||
|
|
||||||
|
// Awalnya gate officer tidak punya izin melihat qma activity log
|
||||||
|
$resDenied = $this->actingAs($gateUser)->get(route('qma.activity.log'));
|
||||||
|
$resDenied->assertForbidden();
|
||||||
|
|
||||||
|
// Super Admin memberikan direct permission qma.logs.view ke user ini
|
||||||
|
$this->actingAs($superAdmin)->post(route('admin.users.update', $gateUser->id), [
|
||||||
|
'name' => $gateUser->name,
|
||||||
|
'username' => $gateUser->username,
|
||||||
|
'email' => $gateUser->email,
|
||||||
|
'role' => 'gate_officer',
|
||||||
|
'direct_permissions' => ['qma.logs.view'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// User langsung dapat mengakses activity log
|
||||||
|
$resAllowed = $this->actingAs($gateUser->fresh())->get(route('qma.activity.log'));
|
||||||
|
$resAllowed->assertOk();
|
||||||
|
|
||||||
|
// Super Admin mencabut izin langsung tersebut
|
||||||
|
$this->actingAs($superAdmin)->post(route('admin.users.update', $gateUser->id), [
|
||||||
|
'name' => $gateUser->name,
|
||||||
|
'username' => $gateUser->username,
|
||||||
|
'email' => $gateUser->email,
|
||||||
|
'role' => 'gate_officer',
|
||||||
|
'direct_permissions' => [],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// User langsung ditolak kembali
|
||||||
|
$resDeniedAgain = $this->actingAs($gateUser->fresh())->get(route('qma.activity.log'));
|
||||||
|
$resDeniedAgain->assertForbidden();
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
-1
@@ -2,9 +2,18 @@
|
|||||||
|
|
||||||
namespace Tests;
|
namespace Tests;
|
||||||
|
|
||||||
|
use Database\Seeders\RolePermissionSeeder;
|
||||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
abstract class TestCase extends BaseTestCase
|
abstract class TestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
//
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
if (Schema::hasTable('permissions') && \Spatie\Permission\Models\Permission::count() === 0) {
|
||||||
|
$this->seed(RolePermissionSeeder::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user