🆙 More fixes 🆙

This commit is contained in:
Remco
2026-01-19 20:43:46 +01:00
parent deed2158ca
commit 7b9849c159
77 changed files with 1084 additions and 13612 deletions
@@ -26,7 +26,7 @@ class InstallationController extends Controller
'installation_key' => ['required', 'string', 'max:255', new ValidateInstallationKeyRule],
]);
WebsiteInstallation::first()->update([
WebsiteInstallation::first()?->update([
'step' => 1,
'user_ip' => $request->ip(),
]);
@@ -38,7 +38,10 @@ class InstallationController extends Controller
{
$settings = $this->getSettingsForStep($currentStep);
return view('installation.step-' . $currentStep, [
/** @var view-string $view */
$view = 'installation.step-' . (string) $currentStep;
return view($view, [
'settings' => $settings,
]);
}
@@ -47,21 +50,27 @@ class InstallationController extends Controller
{
$this->updateSettings($request);
WebsiteInstallation::increment('step');
WebsiteInstallation::query()->increment('step');
/** @var \App\Models\Miscellaneous\WebsiteInstallation|null $installation */
$installation = WebsiteInstallation::first();
return to_route('installation.show-step', WebsiteInstallation::first()->step);
return to_route('installation.show-step', $installation->step ?? 1);
}
public function previousStep(): RedirectResponse
{
WebsiteInstallation::decrement('step');
WebsiteInstallation::query()->decrement('step');
return to_route('installation.show-step', WebsiteInstallation::first()->step);
/** @var \App\Models\Miscellaneous\WebsiteInstallation|null $installation */
$installation = WebsiteInstallation::first();
return to_route('installation.show-step', $installation->step ?? 1);
}
public function restartInstallation(): RedirectResponse
{
WebsiteInstallation::first()->update([
WebsiteInstallation::first()?->update([
'step' => 0,
'installation_key' => Str::uuid(),
'user_ip' => null,
@@ -76,7 +85,7 @@ class InstallationController extends Controller
public function completeInstallation(): RedirectResponse
{
WebsiteInstallation::latest()->first()->update([
WebsiteInstallation::latest()->first()?->update([
'completed' => true,
]);
@@ -100,10 +109,20 @@ class InstallationController extends Controller
}
}
/**
* @return \Illuminate\Database\Eloquent\Collection<int, \App\Models\Miscellaneous\WebsiteSetting>
*/
private function getSettingsForStep(int $step): \Illuminate\Database\Eloquent\Collection
{
$settingsData = array_chunk(WebsiteSetting::all()->pluck('key')->toArray(), ceil(WebsiteSetting::count() / 4));
$count = WebsiteSetting::count();
/** @var int<1, max> $chunkSize */
$chunkSize = $count > 0 ? (int) ceil($count / 4) : 1;
/** @var array<int, string> $keys */
$keys = WebsiteSetting::query()->pluck('key')->toArray();
$settingsData = array_chunk($keys, $chunkSize);
/** @var array<int, string> $settings */
$settings = match ($step) {
1 => $settingsData[0] ?? [],
2 => $settingsData[1] ?? [],
@@ -33,9 +33,11 @@ class LogoGeneratorController extends Controller
$setting = WebsiteSetting::where('key', 'cms_logo')->first();
$setting->update([
'value' => sprintf('%s/%s', $path, $filename),
]);
if ($setting) {
$setting->update([
'value' => sprintf('%s/%s', $path, $filename),
]);
}
return response()->json(['success' => true, 'message' => 'Logo updated!']);
}