69 lines
2.3 KiB
PHP
69 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Prototype\ResourceController;
|
|
use App\Support\Prototype\AdminData;
|
|
use Illuminate\Support\Collection;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class OperatorController extends ResourceController
|
|
{
|
|
private const STATUS = ['Aktif' => 'Aktif', 'Cuti' => 'Cuti', 'Nonaktif' => 'Nonaktif'];
|
|
|
|
protected function rows(): Collection
|
|
{
|
|
return AdminData::operator();
|
|
}
|
|
|
|
protected function routeBase(): string
|
|
{
|
|
return 'admin.operator';
|
|
}
|
|
|
|
protected function names(): array
|
|
{
|
|
return ['singular' => 'Operator', 'plural' => 'Operator', 'description' => 'Staf operator akademik di tingkat universitas dan fakultas.'];
|
|
}
|
|
|
|
protected function keyName(): string
|
|
{
|
|
return 'nip';
|
|
}
|
|
|
|
protected function search(): array
|
|
{
|
|
return ['nip', 'nama', 'unit', 'email'];
|
|
}
|
|
|
|
protected function filters(): array
|
|
{
|
|
return [['name' => 'status', 'label' => 'Status', 'options' => self::STATUS]];
|
|
}
|
|
|
|
protected function columns(): array
|
|
{
|
|
return [
|
|
['label' => 'NIP', 'key' => 'nip'],
|
|
['label' => 'Nama', 'key' => 'nama'],
|
|
['label' => 'Unit kerja', 'key' => 'unit'],
|
|
['label' => 'Jabatan', 'key' => 'jabatan'],
|
|
['label' => 'Status', 'key' => 'status', 'badge' => fn (array $r): string => match ($r['status']) {
|
|
'Aktif' => 'success', 'Cuti' => 'gold', default => 'danger',
|
|
}],
|
|
];
|
|
}
|
|
|
|
protected function fields(?array $row): array
|
|
{
|
|
return [
|
|
['name' => 'nip', 'label' => 'NIP', 'rules' => ['required', 'digits:18'], 'attrs' => ['maxlength' => 18]],
|
|
['name' => 'nama', 'label' => 'Nama lengkap', 'rules' => ['required', 'string', 'max:150']],
|
|
['name' => 'email', 'label' => 'Email', 'type' => 'email', 'rules' => ['required', 'email', 'max:150']],
|
|
['name' => 'unit', 'label' => 'Unit kerja', 'rules' => ['required', 'string', 'max:150']],
|
|
['name' => 'jabatan', 'label' => 'Jabatan', 'rules' => ['required', 'string', 'max:100']],
|
|
['name' => 'status', 'label' => 'Status', 'type' => 'select', 'options' => self::STATUS, 'rules' => ['required', Rule::in(array_keys(self::STATUS))]],
|
|
];
|
|
}
|
|
}
|