fix some bugs from accounting 9

This commit is contained in:
2026-07-28 21:57:29 +03:30
parent 736d0a4fd1
commit 77e0ba0bb3
4 changed files with 109 additions and 14 deletions
@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
/**
* جداسازی اعلان ادمین از اعلان سیستمی (تراکنش‌ها).
*/
return new class extends Migration
{
public function up(): void
{
if (! Schema::hasTable('app_notifications')) {
return;
}
if (! Schema::hasColumn('app_notifications', 'is_system')) {
Schema::table('app_notifications', function (Blueprint $table) {
$table->boolean('is_system')->default(false)->after('created_by')->index();
});
}
// بک‌فیل: سیستمی = بدون created_by یا لیبل قدیمی «سیستمی»
DB::table('app_notifications')
->where(function ($q) {
$q->whereNull('created_by')
->orWhere('audience_label', 'like', 'سیستمی%');
})
->update(['is_system' => true]);
}
public function down(): void
{
if (Schema::hasTable('app_notifications') && Schema::hasColumn('app_notifications', 'is_system')) {
Schema::table('app_notifications', function (Blueprint $table) {
$table->dropColumn('is_system');
});
}
}
};