Browse Source

Fix Ticketmigration (#825)

Dennis 2 years ago
parent
commit
b4b61bcc47

+ 7 - 7
app/Settings/GeneralSettings.php

@@ -8,13 +8,13 @@ class GeneralSettings extends Settings
 {
     public bool $store_enabled;
     public string $credits_display_name;
-    public bool $recaptcha_enabled;
-    public string $recaptcha_site_key;
-    public string $recaptcha_secret_key;
-    public string $phpmyadmin_url;
-    public bool $alert_enabled;
+    public ?bool $recaptcha_enabled;
+    public ?string $recaptcha_site_key;
+    public ?string $recaptcha_secret_key;
+    public ?string $phpmyadmin_url;
+    public ?bool $alert_enabled;
     public string $alert_type;
-    public string $alert_message;
+    public ?string $alert_message;
     public string $theme;
 
     //public int $initial_user_role; wait for Roles & Permissions PR.
@@ -41,7 +41,7 @@ class GeneralSettings extends Settings
             'phpmyadmin_url' => 'nullable|string',
             'alert_enabled' => 'nullable|boolean',
             'alert_type' => 'required|in:primary,secondary,success,danger,warning,info',
-            'alert_message' => 'required|string',
+            'alert_message' => 'nullable|string',
             'theme' => 'required|in:default,BlueInfinity' // TODO: themes should be made/loaded dynamically
         ];
     }

+ 7 - 1
database/settings/2023_02_04_181156_create_ticket_settings.php

@@ -10,7 +10,8 @@ class CreateTicketSettings extends SettingsMigration
         $table_exists = DB::table('settings_old')->exists();
 
         // Get the user-set configuration values from the old table.
-        $this->migrator->add('ticket.enabled', $table_exists ? $this->getOldValue('SETTINGS::TICKET:ENABLED') : 'all');
+        $this->migrator->add('ticket.enabled', $table_exists ? $this->getOldValue('SETTINGS::TICKET:ENABLED') : 'true');
+        $this->migrator->add('ticket.notify', $table_exists ? $this->getOldValue('SETTINGS::TICKET:NOTIFY') : 'all');
     }
 
     public function down(): void
@@ -57,11 +58,16 @@ class CreateTicketSettings extends SettingsMigration
         $old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
 
         // Handle the old values to return without it being a string in all cases.
+
+        if (is_null($old_value)) {
+            return '';
+        }
         if ($old_value->type === "string" || $old_value->type === "text") {
             if (is_null($old_value->value)) {
                 return '';
             }
 
+
             // Some values have the type string, but their values are boolean.
             if ($old_value->value === "false" || $old_value->value === "true") {
                 return filter_var($old_value->value, FILTER_VALIDATE_BOOL);

+ 1 - 0
database/settings/2023_05_07_195343_ticket_information.php

@@ -6,6 +6,7 @@ return new class extends SettingsMigration
 {
     public function up(): void
     {
+        $this->migrator->delete('ticket.notify');
         $this->migrator->add('ticket.information',  "Can't start your server? Need an additional port? Do you have any other questions? Let us know by opening a ticket.");
     }
 };

+ 3 - 2
themes/default/views/admin/settings/index.blade.php

@@ -121,10 +121,11 @@
                                                                     @case($value['type'] == 'select')
                                                                         <select id="{{ $key }}"
                                                                             class="custom-select w-100" name="{{ $key }}">
-                                                                            @foreach ($value['options'] as $option)
+
+                                                                            @foreach ($value['options'] as $option=>$display)
                                                                                 <option value="{{ $option }}"
                                                                                     {{ $value['value'] == $option ? 'selected' : '' }}>
-                                                                                    {{ __($option) }}
+                                                                                    {{ __($display) }}
                                                                                 </option>
                                                                             @endforeach
                                                                         </select>