This commit is contained in:
baodev0
2026-10-08 11:25:28 +07:00
parent 1544629a1f
commit 8651dde6b1
45 changed files with 1543 additions and 357 deletions
@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
private const SCENARIOS = [
'service_expiry',
'service_renewal_reminder',
'invoice_notification',
'invoice_payment_reminder',
];
public function up(): void
{
$this->update(fn (array $disabled) => array_values(array_unique([...$disabled, ...self::SCENARIOS])));
}
public function down(): void
{
$this->update(fn (array $disabled) => array_values(array_diff($disabled, self::SCENARIOS)));
}
private function update(callable $change): void
{
$row = DB::table('setting')->where('key', 'email_settings')->first();
$value = $row ? (json_decode($row->value, true) ?: []) : [];
$value['auto_disabled'] = $change((array) ($value['auto_disabled'] ?? []));
DB::table('setting')->updateOrInsert(
['key' => 'email_settings'],
['value' => json_encode($value), 'updated_at' => now()],
);
}
};