diff --git a/app/Models/SiteSetting.php b/app/Models/SiteSetting.php new file mode 100644 index 0000000..9ed028f --- /dev/null +++ b/app/Models/SiteSetting.php @@ -0,0 +1,14 @@ +pluck('setting_value', 'setting_key')->toArray(); + Cache::put(self::$cacheKey, $settings, 3600); // Cache for 1 hour + } + + // Get a setting value by key + public static function get($key, $default = null) + { + $settings = Cache::get(self::$cacheKey, []); + return $settings[$key] ?? $default; + } + + // Set a setting value by key + public static function set($key, $value) + { + // Update the database + SiteSetting::updateOrCreate(['setting_key' => $key], ['setting_value' => $value]); + + // Update the cache + $settings = Cache::get(self::$cacheKey, []); + $settings[$key] = $value; + Cache::put(self::$cacheKey, $settings, 3600); // Cache for 1 hour + } + + // Clear the cache + public static function clearCache() + { + Cache::forget(self::$cacheKey); + } +} diff --git a/database/migrations/2024_06_01_163911_create_site_settings_table.php b/database/migrations/2024_06_01_163911_create_site_settings_table.php new file mode 100644 index 0000000..01149e7 --- /dev/null +++ b/database/migrations/2024_06_01_163911_create_site_settings_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('setting_key')->unique(); + $table->text('setting_value'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('site_settings'); + } +}; diff --git a/resources/views/test.blade.php b/resources/views/test.blade.php index f396f65..b57098a 100644 --- a/resources/views/test.blade.php +++ b/resources/views/test.blade.php @@ -1,16 +1,11 @@ -@php use App\Models\Audition;use App\Models\School;use App\Models\SchoolEmailDomain;use App\Models\User;use Illuminate\Support\Facades\Auth;use Illuminate\Support\Facades\Session; @endphp +@php use App\Models\Audition;use App\Models\School;use App\Models\SchoolEmailDomain;use App\Models\User;use App\Settings;use Illuminate\Support\Facades\Auth;use Illuminate\Support\Facades\Session; @endphp Test Page - @php -// $flash = Session::get('_flash'); -// $messages = $flash['new']; - $messages = getMessages(); - @endphp + @php( Settings::set('auditionName','Somewhere Band Directors Association')) + @php( Settings::set('auditionAbbreviation','SBDA')) - - @foreach($messages as $message) - The message "{{ $message['message'] }}" is of type "{{ $message['type'] }}"
- @endforeach + {{ Settings::get('auditionName') }}
+d