Commit awal: prototipe UI SIAKAD Untan
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Models\Admin\Admin;
|
||||
use App\Models\Dosen\Dosen;
|
||||
use App\Models\Mahasiswa\Mahasiswa;
|
||||
use App\Models\Operator\Operator;
|
||||
use App\Models\Superuser\Superuser;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
enum Role: string
|
||||
{
|
||||
case Superuser = 'superuser';
|
||||
case Admin = 'admin';
|
||||
case Operator = 'operator';
|
||||
case Dosen = 'dosen';
|
||||
case Mahasiswa = 'mahasiswa';
|
||||
|
||||
/** Nama tampilan dalam bahasa Indonesia. */
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Superuser => 'Superuser',
|
||||
self::Admin => 'Admin',
|
||||
self::Operator => 'Operator',
|
||||
self::Dosen => 'Dosen',
|
||||
self::Mahasiswa => 'Mahasiswa',
|
||||
};
|
||||
}
|
||||
|
||||
/** Nama ikon Heroicon (tanpa awalan) untuk pemilih peran. */
|
||||
public function roleIcon(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Superuser => 'shield-check',
|
||||
self::Admin => 'cog-6-tooth',
|
||||
self::Operator => 'computer-desktop',
|
||||
self::Dosen => 'academic-cap',
|
||||
self::Mahasiswa => 'user',
|
||||
};
|
||||
}
|
||||
|
||||
/** Nama route dashboard milik role ini. */
|
||||
public function dashboardRoute(): string
|
||||
{
|
||||
return $this->value.'.dashboard';
|
||||
}
|
||||
|
||||
public function routePrefix(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/** Nama relasi profil pada model User. */
|
||||
public function profileRelation(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/** @return class-string<Model> */
|
||||
public function profileModel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Superuser => Superuser::class,
|
||||
self::Admin => Admin::class,
|
||||
self::Operator => Operator::class,
|
||||
self::Dosen => Dosen::class,
|
||||
self::Mahasiswa => Mahasiswa::class,
|
||||
};
|
||||
}
|
||||
|
||||
/** Label nomor induk: NIP, NIDN, atau NIM. */
|
||||
public function identifierLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Superuser, self::Admin, self::Operator => 'NIP',
|
||||
self::Dosen => 'NIDN',
|
||||
self::Mahasiswa => 'NIM',
|
||||
};
|
||||
}
|
||||
|
||||
/** @return list<string> */
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
|
||||
/** @return array<string, string> value => label */
|
||||
public static function options(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (self::cases() as $role) {
|
||||
$options[$role->value] = $role->label();
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user