Bring back winter snow effect, gated by an admin setting
The site has flip-flopped on the snow effect every winter (add it, remove it, repeat), meaning a PR round-trip each time. Instead, restore the winter.js/is-land assets and gate them behind a new admin-toggleable setting so the effect can be switched on/off from /admin/settings without touching code. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0113BVPXDpEk9HPEqXvSG2WQ
This commit is contained in:
parent
e9d8f4c74b
commit
9532aae37e
18 changed files with 377 additions and 0 deletions
32
app/Http/Controllers/Admin/SettingsController.php
Normal file
32
app/Http/Controllers/Admin/SettingsController.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
public function show(): View
|
||||
{
|
||||
$settings = Setting::first();
|
||||
|
||||
return view('admin.settings.show', [
|
||||
'settings' => $settings,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request): RedirectResponse
|
||||
{
|
||||
$settings = Setting::firstOrNew();
|
||||
$settings->winter_effect_enabled = $request->boolean('winter_effect_enabled');
|
||||
$settings->save();
|
||||
|
||||
return redirect()->route('admin.settings.show');
|
||||
}
|
||||
}
|
||||
18
app/Models/Setting.php
Normal file
18
app/Models/Setting.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Setting extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'winter_effect_enabled' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
|
@ -2,10 +2,12 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Symfony\Component\HtmlSanitizer\HtmlSanitizer;
|
||||
use Symfony\Component\HtmlSanitizer\HtmlSanitizerConfig;
|
||||
|
|
@ -63,5 +65,10 @@ class AppServiceProvider extends ServiceProvider
|
|||
|
||||
// Force HTTPS URL generation in production
|
||||
URL::forceHttps($this->app->isProduction());
|
||||
|
||||
// Share whether the winter snow effect is enabled with the base layout
|
||||
View::composer('master', function ($view) {
|
||||
$view->with('winterEffectEnabled', Setting::first()?->winter_effect_enabled ?? false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue