middleware(RedirectIfInstalled::class);
}
public function installation(Requirement $requirement, Permission $permission): Factory|View|Application
{
return view('install.install', compact('requirement', 'permission'));
}
public function install(
InstallRequest $request,
Database $database,
AdminAccount $admin,
Store $store,
App $app
): JsonResponse
{
@set_time_limit(0);
try {
Artisan::call('optimize:clear');
$database->setup($request);
$admin->setup($request);
$store->setup($request);
$app->setup();
DotenvEditor::setKey('APP_INSTALLED', 'true')->save();
Artisan::call('key:generate', ['--force' => true]);
$success = true;
$message = "Congratulations! FleetCart installed successfully";
} catch (Exception $e) {
$success = false;
$message = $e->getMessage();
try {
if (Schema::hasTable('migrations')) {
Artisan::call('migrate:rollback', ['--force' => true]);
}
} catch (Exception $e) {
$message .= '
' . $e->getMessage();
}
} finally {
return response()->json(
[
'success' => $success,
'message' => $message,
],
$success ? Response::HTTP_OK : Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
}