[Superuser] Integrasi Pertama ke Database
This commit is contained in:
@@ -4,6 +4,9 @@ namespace App\Http\Controllers\Superuser;
|
||||
|
||||
use App\Enums\Role;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Legacy\Account;
|
||||
use App\Support\Legacy\LoginHistory;
|
||||
use App\Support\Legacy\SystemOverview;
|
||||
use App\Support\Prototype\Sample;
|
||||
use App\Support\Prototype\SuperuserData;
|
||||
use Illuminate\Contracts\View\View;
|
||||
@@ -12,7 +15,7 @@ use Illuminate\Support\Carbon;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request): View
|
||||
public function __invoke(Request $request, SystemOverview $overview, LoginHistory $history): View
|
||||
{
|
||||
$role = Role::Superuser;
|
||||
$user = $request->user()->loadMissing($role->profileRelation());
|
||||
@@ -26,6 +29,24 @@ class DashboardController extends Controller
|
||||
'Unit kerja' => $profile?->unit_kerja,
|
||||
], fn (mixed $value): bool => $value !== null));
|
||||
|
||||
// Akun DB lama: ringkasan asli akun, otoritas, dan riwayat masuk dari t_account, t_otoritasuser, dan t_historilogin.
|
||||
if ($user instanceof Account) {
|
||||
$authorities = $overview->authorities();
|
||||
$logins = $overview->logins();
|
||||
|
||||
return view('superuser.dashboard-legacy', [
|
||||
'user' => $user,
|
||||
'details' => $details,
|
||||
'accounts' => $overview->accounts(),
|
||||
'authorityLabels' => array_keys($authorities),
|
||||
'authorityData' => array_values($authorities),
|
||||
'loginLabels' => array_map(strval(...), array_keys($logins['tahun'])),
|
||||
'loginData' => array_values($logins['tahun']),
|
||||
'lastLogin' => $logins['terakhir'],
|
||||
'latest' => $history->latest(),
|
||||
]);
|
||||
}
|
||||
|
||||
$pengguna = SuperuserData::pengguna();
|
||||
$aktivitas = SuperuserData::aktivitas();
|
||||
$cadangan = SuperuserData::cadangan();
|
||||
|
||||
Reference in New Issue
Block a user