added notif 2
This commit is contained in:
@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* سوییچ اعلان / هشدار قیمت برای اپ کاربر — پیشفرض false، can_edit=0.
|
||||
* هشدار قیمت — پیشفرض true، can_edit=0.
|
||||
* value ردیف موجود را تغییر نمیدهد.
|
||||
*/
|
||||
return new class extends Migration
|
||||
@@ -13,8 +13,8 @@ return new class extends Migration
|
||||
{
|
||||
$key = 'has_page_price_trigger';
|
||||
$meta = [
|
||||
'title_fa' => 'اعلان (هشدار قیمت)',
|
||||
'description' => 'روشن: منوی هشدار قیمت (اعلان) در اپ کاربر نمایش داده میشود. خاموش: منو و صفحه مخفی است. فقط از دیپلوی قابل تغییر است.',
|
||||
'title_fa' => 'هشدار قیمت',
|
||||
'description' => 'روشن: منوی هشدار قیمت در اپ کاربر نمایش داده میشود. خاموش: منو و صفحه مخفی است. فقط از دیپلوی قابل تغییر است.',
|
||||
'type' => 'switch',
|
||||
];
|
||||
|
||||
@@ -22,7 +22,7 @@ return new class extends Migration
|
||||
if (! $exists) {
|
||||
DB::table('settings')->insert([
|
||||
'key' => $key,
|
||||
'value' => 'false',
|
||||
'value' => 'true',
|
||||
'title_fa' => $meta['title_fa'],
|
||||
'can_edit' => 0,
|
||||
'is_active' => 1,
|
||||
@@ -44,6 +44,6 @@ return new class extends Migration
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// کلید را حذف نمیکنیم — ممکن است مقدار ادمین داشته باشد.
|
||||
// کلید را حذف نمیکنیم
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* اعلان داخل اپ (از ادمین به مشتری) + سوییچ has_page_notification.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('app_notifications')) {
|
||||
Schema::create('app_notifications', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title', 191);
|
||||
$table->text('body');
|
||||
$table->string('severity', 16)->default('info'); // info|success|warning|danger
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->unsignedBigInteger('created_by')->nullable()->index();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
if (! Schema::hasTable('app_notification_reads')) {
|
||||
Schema::create('app_notification_reads', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('notification_id')->index();
|
||||
$table->unsignedBigInteger('customer_id')->index();
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->unique(['notification_id', 'customer_id'], 'app_notif_reads_unique');
|
||||
});
|
||||
}
|
||||
|
||||
$key = 'has_page_notification';
|
||||
$meta = [
|
||||
'title_fa' => 'اعلان داخل اپ',
|
||||
'description' => 'روشن: زنگوله اعلان در اپ کاربر و منوی ثبت اعلان در ادمین فعال است. خاموش: مخفی است. فقط از دیپلوی قابل تغییر است.',
|
||||
'type' => 'switch',
|
||||
];
|
||||
|
||||
$exists = DB::table('settings')->where('key', $key)->exists();
|
||||
if (! $exists) {
|
||||
DB::table('settings')->insert([
|
||||
'key' => $key,
|
||||
'value' => 'false',
|
||||
'title_fa' => $meta['title_fa'],
|
||||
'can_edit' => 0,
|
||||
'is_active' => 1,
|
||||
'description' => $meta['description'],
|
||||
'type' => $meta['type'],
|
||||
]);
|
||||
} else {
|
||||
DB::table('settings')->where('key', $key)->update([
|
||||
'title_fa' => $meta['title_fa'],
|
||||
'description' => $meta['description'],
|
||||
'type' => $meta['type'],
|
||||
'can_edit' => 0,
|
||||
'is_active' => 1,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('app_notification_reads');
|
||||
Schema::dropIfExists('app_notifications');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user