2023-02-05 17:20:55 +00:00
|
|
|
<?php
|
|
|
|
|
2024-04-12 12:04:26 +00:00
|
|
|
use App\Classes\LegacySettingsMigration;
|
2023-02-05 17:20:55 +00:00
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
2024-04-12 12:04:26 +00:00
|
|
|
class CreateTicketSettings extends LegacySettingsMigration
|
2023-02-05 17:20:55 +00:00
|
|
|
{
|
|
|
|
public function up(): void
|
|
|
|
{
|
|
|
|
$table_exists = DB::table('settings_old')->exists();
|
|
|
|
|
|
|
|
// Get the user-set configuration values from the old table.
|
2023-05-08 10:26:49 +00:00
|
|
|
$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');
|
2023-02-18 23:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function down(): void
|
|
|
|
{
|
|
|
|
DB::table('settings_old')->insert([
|
|
|
|
[
|
|
|
|
'key' => 'SETTINGS::TICKET:NOTIFY',
|
2024-04-12 19:01:49 +00:00
|
|
|
'value' => $this->getNewValue('notify', 'ticket'),
|
2023-02-18 23:34:26 +00:00
|
|
|
'type' => 'string',
|
|
|
|
'description' => 'The notification type for tickets.',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'key' => 'SETTINGS::TICKET:ENABLED',
|
2024-04-12 19:01:49 +00:00
|
|
|
'value' => $this->getNewValue('enabled', 'ticket'),
|
2023-02-18 23:34:26 +00:00
|
|
|
'type' => 'boolean',
|
|
|
|
'description' => 'Enable or disable the ticket system.',
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
|
2024-04-12 19:01:49 +00:00
|
|
|
try {
|
|
|
|
$this->migrator->delete('ticket.enabled');
|
|
|
|
$this->migrator->delete('ticket.notify');
|
|
|
|
} catch (Exception $e) {
|
|
|
|
// Do nothing.
|
|
|
|
}
|
2023-02-18 23:34:26 +00:00
|
|
|
}
|
2023-02-05 17:20:55 +00:00
|
|
|
}
|