From 2413849f130e71493839684d579a52ed67000fd0 Mon Sep 17 00:00:00 2001 From: Arya Dwi Putra Date: Tue, 2 Dec 2025 18:21:32 +0700 Subject: [PATCH] Use UUID-aware Role model in setup wizard --- .../Controllers/SetupWizardController.php | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/SetupWizardController.php b/app/Http/Controllers/SetupWizardController.php index bced169..1fd8f5e 100644 --- a/app/Http/Controllers/SetupWizardController.php +++ b/app/Http/Controllers/SetupWizardController.php @@ -16,9 +16,10 @@ use App\Models\Warranty; use App\Services\Asset\AssetService; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Hash; use Illuminate\View\View; -use Spatie\Permission\Models\Role; +use App\Models\Role; // pakai model lokal yang sudah memakai UUID dan accessor id->uuid class SetupWizardController extends Controller { @@ -132,4 +133,21 @@ class SetupWizardController extends Controller return back()->with('error', 'Langkah tidak dikenal.'); } + + public function migrate(Request $request): RedirectResponse + { + $withSample = $request->boolean('with_sample'); + try { + Artisan::call('migrate', ['--force' => true]); + if ($withSample) { + Artisan::call('db:seed', ['--force' => true]); + } else { + // Seed minimal RBAC agar wizard dapat berjalan + Artisan::call('db:seed', ['--force' => true, '--class' => 'Database\\Seeders\\RbacSeeder']); + } + return redirect()->route('setup.index', ['step' => 1])->with('success', 'Migrasi berhasil' . ($withSample ? ' dengan sample data.' : '.')); + } catch (\Throwable $e) { + return redirect()->route('setup.index')->withErrors(['db' => 'Migrasi gagal: '.$e->getMessage()]); + } + } }