diff --git a/app/Http/Controllers/Admin/AppNotificationController.php b/app/Http/Controllers/Admin/AppNotificationController.php new file mode 100644 index 0000000..7e97cb1 --- /dev/null +++ b/app/Http/Controllers/Admin/AppNotificationController.php @@ -0,0 +1,76 @@ +all()) + ->initSearch(['title', 'body', 'severity']) + ->select(['*']) + ->export($query); + + return $query; + } + + public function store(Request $request) + { + $data = $this->validatedPayload($request); + $user = auth()->user(); + + $row = AppNotification::create([ + ...$data, + 'is_active' => $data['is_active'] ?? true, + 'created_by' => $user?->id, + ]); + + return response()->json($row, 201); + } + + public function update(Request $request, int $id) + { + $row = AppNotification::findOrFail($id); + $data = $this->validatedPayload($request, true); + $row->update($data); + + return response()->json(true); + } + + public function toggleActive(int $id) + { + $row = AppNotification::findOrFail($id); + $row->is_active = ! $row->is_active; + $row->save(); + + return response()->json([ + 'is_active' => (bool) $row->is_active, + ]); + } + + public function destroy(int $id) + { + AppNotification::findOrFail($id)->delete(); + + return response()->json(true); + } + + private function validatedPayload(Request $request, bool $partial = false): array + { + $rules = [ + 'title' => ($partial ? 'sometimes|' : '') . 'required|string|max:191', + 'body' => ($partial ? 'sometimes|' : '') . 'required|string|max:5000', + 'severity' => ($partial ? 'sometimes|' : '') . 'required|in:info,success,warning,danger', + 'is_active' => 'sometimes|boolean', + ]; + + return $request->validate($rules); + } +} diff --git a/app/Http/Controllers/Customer/AppNotificationController.php b/app/Http/Controllers/Customer/AppNotificationController.php new file mode 100644 index 0000000..7b68584 --- /dev/null +++ b/app/Http/Controllers/Customer/AppNotificationController.php @@ -0,0 +1,122 @@ +getBool('has_page_notification', false)) { + throw new NotFoundHttpException('اعلان داخل اپ غیرفعال است.'); + } + } + + public function index() + { + $this->assertFeatureEnabled(); + $customerId = (int) auth()->id(); + + $rows = AppNotification::query() + ->where('is_active', true) + ->orderByDesc('id') + ->limit(100) + ->get(['id', 'title', 'body', 'severity', 'created_at']); + + $readIds = AppNotificationRead::query() + ->where('customer_id', $customerId) + ->whereIn('notification_id', $rows->pluck('id')) + ->pluck('notification_id') + ->all(); + $readSet = array_fill_keys($readIds, true); + + $payload = $rows->map(function (AppNotification $row) use ($readSet) { + return [ + 'id' => $row->id, + 'title' => $row->title, + 'body' => $row->body, + 'severity' => $row->severity, + 'created_at' => $row->created_at, + 'is_read' => isset($readSet[$row->id]), + ]; + }); + + return response()->json($payload); + } + + public function unreadCount() + { + $this->assertFeatureEnabled(); + $customerId = (int) auth()->id(); + + $total = AppNotification::query()->where('is_active', true)->count(); + $read = AppNotificationRead::query() + ->where('customer_id', $customerId) + ->whereIn( + 'notification_id', + AppNotification::query()->where('is_active', true)->select('id') + ) + ->count(); + + return response()->json([ + 'unread_count' => max(0, $total - $read), + ]); + } + + public function markRead(Request $request, int $id) + { + $this->assertFeatureEnabled(); + $customerId = (int) auth()->id(); + + $exists = AppNotification::query() + ->where('id', $id) + ->where('is_active', true) + ->exists(); + if (! $exists) { + throw new NotFoundHttpException('اعلان یافت نشد.'); + } + + AppNotificationRead::query()->updateOrCreate( + [ + 'notification_id' => $id, + 'customer_id' => $customerId, + ], + [ + 'read_at' => now(), + ] + ); + + return response()->json(true); + } + + public function markAllRead() + { + $this->assertFeatureEnabled(); + $customerId = (int) auth()->id(); + + $ids = AppNotification::query() + ->where('is_active', true) + ->pluck('id'); + + $now = now(); + foreach ($ids as $notificationId) { + AppNotificationRead::query()->updateOrCreate( + [ + 'notification_id' => $notificationId, + 'customer_id' => $customerId, + ], + [ + 'read_at' => $now, + ] + ); + } + + return response()->json(true); + } +} diff --git a/app/Models/AppNotification.php b/app/Models/AppNotification.php new file mode 100644 index 0000000..dfd2756 --- /dev/null +++ b/app/Models/AppNotification.php @@ -0,0 +1,31 @@ + 'boolean', + ]; + + public function reads(): HasMany + { + return $this->hasMany(AppNotificationRead::class, 'notification_id'); + } +} diff --git a/app/Models/AppNotificationRead.php b/app/Models/AppNotificationRead.php new file mode 100644 index 0000000..d192357 --- /dev/null +++ b/app/Models/AppNotificationRead.php @@ -0,0 +1,26 @@ + 'datetime', + ]; + + public function notification(): BelongsTo + { + return $this->belongsTo(AppNotification::class, 'notification_id'); + } +} diff --git a/database/migrations/2026_07_23_000003_add_has_page_price_trigger_setting.php b/database/migrations/2026_07_23_000003_add_has_page_price_trigger_setting.php index a376f8a..36425eb 100644 --- a/database/migrations/2026_07_23_000003_add_has_page_price_trigger_setting.php +++ b/database/migrations/2026_07_23_000003_add_has_page_price_trigger_setting.php @@ -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 { - // کلید را حذف نمی‌کنیم — ممکن است مقدار ادمین داشته باشد. + // کلید را حذف نمی‌کنیم } }; diff --git a/database/migrations/2026_07_23_000004_create_app_notifications_tables.php b/database/migrations/2026_07_23_000004_create_app_notifications_tables.php new file mode 100644 index 0000000..3a5bad3 --- /dev/null +++ b/database/migrations/2026_07_23_000004_create_app_notifications_tables.php @@ -0,0 +1,73 @@ +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'); + } +}; diff --git a/database/sql/deploy_settings_const.sql b/database/sql/deploy_settings_const.sql index 6b6c595..7abdb5e 100644 --- a/database/sql/deploy_settings_const.sql +++ b/database/sql/deploy_settings_const.sql @@ -360,11 +360,17 @@ SELECT 'enable_conditional_order', 'false', 'سفارش شرطی', 0, 1, WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'enable_conditional_order' LIMIT 1); INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) -SELECT 'has_page_price_trigger', 'false', 'اعلان (هشدار قیمت)', 0, 1, - 'روشن: منوی هشدار قیمت (اعلان) در اپ کاربر نمایش داده می‌شود. خاموش: منو و صفحه مخفی است. فقط از دیپلوی قابل تغییر است.', +SELECT 'has_page_price_trigger', 'true', 'هشدار قیمت', 0, 1, + 'روشن: منوی هشدار قیمت در اپ کاربر نمایش داده می‌شود. خاموش: منو و صفحه مخفی است. فقط از دیپلوی قابل تغییر است.', 'switch' WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'has_page_price_trigger' LIMIT 1); +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'has_page_notification', 'false', 'اعلان داخل اپ', 0, 1, + 'روشن: زنگوله اعلان در اپ کاربر و منوی ثبت اعلان در ادمین فعال است. خاموش: مخفی است. فقط از دیپلوی قابل تغییر است.', + 'switch' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'has_page_notification' LIMIT 1); + INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) SELECT 'jibit_enabled', 'true', 'احراز هویت جیبیت', 0, 1, 'روشن: سرویس احراز هویت جیبیت (تطبیق کد ملی/موبایل و کارت بانکی) فعال است. خاموش: هیچ فراخوانی به جیبیت انجام نمی‌شود و احراز هویت خودکار کار نمی‌کند. فقط از صفحه دیپلوی قابل تغییر است.', @@ -810,7 +816,7 @@ UPDATE `settings` SET `title_fa` = 'متن درباره ما' WHERE `key` = 'tex UPDATE `settings` SET `title_fa` = 'صفحه کسب درآمد' WHERE `key` = 'has_page_earn_money' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); UPDATE `settings` SET `title_fa` = 'صفحه صندوق' WHERE `key` = 'has_page_fund' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); UPDATE `settings` SET `title_fa` = 'صفحه مجوزها' WHERE `key` = 'has_page_permission' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); -UPDATE `settings` SET `title_fa` = 'اعلان (هشدار قیمت)' WHERE `key` = 'has_page_price_trigger' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'هشدار قیمت' WHERE `key` = 'has_page_price_trigger' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); UPDATE `settings` SET `title_fa` = 'صفحه طلای فیزیکی' WHERE `key` = 'has_page_physical_gold' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); UPDATE `settings` SET `title_fa` = 'رنگ اصلی' WHERE `key` = 'color_primary' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); UPDATE `settings` SET `title_fa` = 'رنگ ثانویه' WHERE `key` = 'color_secondary' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); @@ -947,7 +953,7 @@ UPDATE `settings` SET `type` = 'switch' WHERE `key` IN ( 'fee_deduct_from_gold', 'require_zero_main_gold_before_other_buy', 'profit_gold_api_enabled', 'payping_round_toman', 'payping_strict_failed_withdraw', - 'has_page_earn_money', 'has_page_price_trigger', 'charge_notif', 'group_sms', 'sms_panel', 'customer_direct_sms', + 'has_page_earn_money', 'has_page_price_trigger', 'has_page_notification', 'charge_notif', 'group_sms', 'sms_panel', 'customer_direct_sms', 'enable_conditional_order', 'sms_notif_order_admin', 'sms_notif_order_customer', 'sms_notif_withdraw_admin', 'sms_notif_withdraw_otp', 'sms_notif_login_otp', @@ -1324,7 +1330,9 @@ UPDATE `settings` SET `description` = 'مبلغ یا مقدار پاداش مع UPDATE `settings` SET `description` = 'روشن: تطبیق شماره کارت بانکی کاربر با سرویس احراز هویت جیبیت هنگام ثبت/ویرایش کارت.' WHERE `key` = 'jibit_verification'; UPDATE `settings` SET `description` = 'روشن: تطبیق کد ملی و موبایل در فرآیند ثبت‌نام از طریق سرویس جیبیت.' WHERE `key` = 'register_jibit_verify'; UPDATE `settings` SET `description` = 'روشن: منوی «کسب درآمد / دعوت دوستان» در اپ کاربر نمایش داده می‌شود.' WHERE `key` = 'has_page_earn_money'; -UPDATE `settings` SET `description` = 'روشن: منوی هشدار قیمت (اعلان) در اپ کاربر نمایش داده می‌شود. خاموش: منو و صفحه مخفی است. فقط از دیپلوی قابل تغییر است.' WHERE `key` = 'has_page_price_trigger'; +UPDATE `settings` SET `description` = 'روشن: منوی هشدار قیمت در اپ کاربر نمایش داده می‌شود. خاموش: منو و صفحه مخفی است. فقط از دیپلوی قابل تغییر است.' WHERE `key` = 'has_page_price_trigger'; +UPDATE `settings` SET `description` = 'روشن: زنگوله اعلان در اپ کاربر و منوی ثبت اعلان در ادمین فعال است. خاموش: مخفی است. فقط از دیپلوی قابل تغییر است.' WHERE `key` = 'has_page_notification'; +UPDATE `settings` SET `title_fa` = 'اعلان داخل اپ' WHERE `key` = 'has_page_notification'; UPDATE `settings` SET `description` = 'شماره موبایل حساب API سرویس همکار قیمت. برای دریافت توکن و لیست محصولات.' WHERE `key` = 'montzar_mobile'; UPDATE `settings` SET `description` = 'رمز عبور حساب API سرویس همکار قیمت. محرمانه نگه دارید.' WHERE `key` = 'montzar_password'; @@ -1519,7 +1527,7 @@ UPDATE `settings` SET `title_fa` = 'صفحه کسب درآمد' WHERE `key` = 'h UPDATE `settings` SET `title_fa` = 'صفحه صندوق' WHERE `key` = 'has_page_fund'; UPDATE `settings` SET `title_fa` = 'صفحه مجوزها' WHERE `key` = 'has_page_permission'; UPDATE `settings` SET `title_fa` = 'صفحه طلای فیزیکی' WHERE `key` = 'has_page_physical_gold'; -UPDATE `settings` SET `title_fa` = 'اعلان (هشدار قیمت)' WHERE `key` = 'has_page_price_trigger'; +UPDATE `settings` SET `title_fa` = 'هشدار قیمت' WHERE `key` = 'has_page_price_trigger'; UPDATE `settings` SET `title_fa` = 'متن دعوتنامه اشتراک‌گذاری' WHERE `key` = 'invite_link_text'; UPDATE `settings` SET `title_fa` = 'حالت فروشگاهی' WHERE `key` = 'is_store'; UPDATE `settings` SET `title_fa` = 'تأیید کارت بانکی با جیبیت' WHERE `key` = 'jibit_verification'; @@ -1632,6 +1640,7 @@ UPDATE `settings` SET `can_edit` = 0 WHERE `key` IN ( 'customer_direct_sms', 'enable_conditional_order', 'has_page_price_trigger', + 'has_page_notification', 'jibit_enabled', 'has_page_earn_money', 'is_store', diff --git a/database/sql/deploy_settings_const_preserve_value_sync_can_edit.sql b/database/sql/deploy_settings_const_preserve_value_sync_can_edit.sql index 464deb9..b707fb7 100644 --- a/database/sql/deploy_settings_const_preserve_value_sync_can_edit.sql +++ b/database/sql/deploy_settings_const_preserve_value_sync_can_edit.sql @@ -315,11 +315,17 @@ SELECT 'enable_conditional_order', 'false', 'سفارش شرطی', 0, 1, WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'enable_conditional_order' LIMIT 1); INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) -SELECT 'has_page_price_trigger', 'false', 'اعلان (هشدار قیمت)', 0, 1, - 'روشن: منوی هشدار قیمت (اعلان) در اپ کاربر نمایش داده می‌شود. خاموش: منو و صفحه مخفی است. فقط از دیپلوی قابل تغییر است.', +SELECT 'has_page_price_trigger', 'true', 'هشدار قیمت', 0, 1, + 'روشن: منوی هشدار قیمت در اپ کاربر نمایش داده می‌شود. خاموش: منو و صفحه مخفی است. فقط از دیپلوی قابل تغییر است.', 'switch' WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'has_page_price_trigger' LIMIT 1); +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'has_page_notification', 'false', 'اعلان داخل اپ', 0, 1, + 'روشن: زنگوله اعلان در اپ کاربر و منوی ثبت اعلان در ادمین فعال است. خاموش: مخفی است. فقط از دیپلوی قابل تغییر است.', + 'switch' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'has_page_notification' LIMIT 1); + INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) SELECT 'jibit_enabled', 'true', 'احراز هویت جیبیت', 0, 1, 'روشن: سرویس احراز هویت جیبیت (تطبیق کد ملی/موبایل و کارت بانکی) فعال است. خاموش: هیچ فراخوانی به جیبیت انجام نمی‌شود و احراز هویت خودکار کار نمی‌کند. فقط از صفحه دیپلوی قابل تغییر است.', @@ -683,7 +689,7 @@ UPDATE `settings` SET `title_fa` = 'متن درباره ما' WHERE `key` = 'tex UPDATE `settings` SET `title_fa` = 'صفحه کسب درآمد' WHERE `key` = 'has_page_earn_money' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); UPDATE `settings` SET `title_fa` = 'صفحه صندوق' WHERE `key` = 'has_page_fund' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); UPDATE `settings` SET `title_fa` = 'صفحه مجوزها' WHERE `key` = 'has_page_permission' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); -UPDATE `settings` SET `title_fa` = 'اعلان (هشدار قیمت)' WHERE `key` = 'has_page_price_trigger' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'هشدار قیمت' WHERE `key` = 'has_page_price_trigger' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); UPDATE `settings` SET `title_fa` = 'صفحه طلای فیزیکی' WHERE `key` = 'has_page_physical_gold' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); UPDATE `settings` SET `title_fa` = 'رنگ اصلی' WHERE `key` = 'color_primary' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); UPDATE `settings` SET `title_fa` = 'رنگ ثانویه' WHERE `key` = 'color_secondary' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); @@ -817,7 +823,7 @@ UPDATE `settings` SET `type` = 'switch' WHERE `key` IN ( 'close_price', 'show_last_price', 'fee_deduct_from_gold', 'send_to_tahesab', 'profit_gold_api_enabled', 'payping_round_toman', 'payping_strict_failed_withdraw', - 'has_page_earn_money', 'has_page_price_trigger', 'charge_notif', 'group_sms', 'sms_panel', 'customer_direct_sms', + 'has_page_earn_money', 'has_page_price_trigger', 'has_page_notification', 'charge_notif', 'group_sms', 'sms_panel', 'customer_direct_sms', 'enable_conditional_order', 'sms_notif_order_admin', 'sms_notif_order_customer', 'sms_notif_withdraw_admin', 'sms_notif_withdraw_otp', 'sms_notif_login_otp', @@ -1210,7 +1216,9 @@ UPDATE `settings` SET `description` = 'مبلغ یا مقدار پاداش مع UPDATE `settings` SET `description` = 'روشن: تطبیق شماره کارت بانکی کاربر با سرویس احراز هویت جیبیت هنگام ثبت/ویرایش کارت.' WHERE `key` = 'jibit_verification'; UPDATE `settings` SET `description` = 'روشن: تطبیق کد ملی و موبایل در فرآیند ثبت‌نام از طریق سرویس جیبیت.' WHERE `key` = 'register_jibit_verify'; UPDATE `settings` SET `description` = 'روشن: منوی «کسب درآمد / دعوت دوستان» در اپ کاربر نمایش داده می‌شود.' WHERE `key` = 'has_page_earn_money'; -UPDATE `settings` SET `description` = 'روشن: منوی هشدار قیمت (اعلان) در اپ کاربر نمایش داده می‌شود. خاموش: منو و صفحه مخفی است. فقط از دیپلوی قابل تغییر است.' WHERE `key` = 'has_page_price_trigger'; +UPDATE `settings` SET `description` = 'روشن: منوی هشدار قیمت در اپ کاربر نمایش داده می‌شود. خاموش: منو و صفحه مخفی است. فقط از دیپلوی قابل تغییر است.' WHERE `key` = 'has_page_price_trigger'; +UPDATE `settings` SET `description` = 'روشن: زنگوله اعلان در اپ کاربر و منوی ثبت اعلان در ادمین فعال است. خاموش: مخفی است. فقط از دیپلوی قابل تغییر است.' WHERE `key` = 'has_page_notification'; +UPDATE `settings` SET `title_fa` = 'اعلان داخل اپ' WHERE `key` = 'has_page_notification'; UPDATE `settings` SET `description` = 'شماره موبایل حساب API سرویس همکار قیمت. برای دریافت توکن و لیست محصولات.' WHERE `key` = 'montzar_mobile'; UPDATE `settings` SET `description` = 'رمز عبور حساب API سرویس همکار قیمت. محرمانه نگه دارید.' WHERE `key` = 'montzar_password'; @@ -1340,6 +1348,7 @@ UPDATE `settings` SET `can_edit` = 0 WHERE `key` IN ( 'customer_direct_sms', 'enable_conditional_order', 'has_page_price_trigger', + 'has_page_notification', 'jibit_enabled', 'has_page_earn_money', 'is_store', diff --git a/routes/admin.php b/routes/admin.php index 0b776cd..1ed7b8c 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -12,6 +12,7 @@ use \App\Http\Controllers\Admin\BankAccountController; use \App\Http\Controllers\Admin\DashboardController; use \App\Http\Controllers\Single\SingleOrderController; use App\Http\Controllers\Admin\PriceTriggerController as AdminPriceTriggerController; +use App\Http\Controllers\Admin\AppNotificationController as AdminAppNotificationController; use App\Http\Controllers\Finance\FinanceController; use App\Http\Controllers\Admin\ProductController; use App\Http\Controllers\Admin\TahesabController; @@ -46,6 +47,13 @@ Route::middleware('auth:user')->group(function (){ Route::put('price_triggers/{id}', [AdminPriceTriggerController::class, 'update']); Route::put('price_triggers/{id}/toggle', [AdminPriceTriggerController::class, 'toggleActive']); Route::delete('price_triggers/{id}', [AdminPriceTriggerController::class, 'destroy']); + + //------------AppNotifications + Route::post('app_notifications/table', [AdminAppNotificationController::class, 'table']); + Route::post('app_notifications', [AdminAppNotificationController::class, 'store']); + Route::put('app_notifications/{id}', [AdminAppNotificationController::class, 'update']); + Route::put('app_notifications/{id}/toggle', [AdminAppNotificationController::class, 'toggleActive']); + Route::delete('app_notifications/{id}', [AdminAppNotificationController::class, 'destroy']); //------------ConditionalOrder Route::post('conditional_orders/table', [\App\Http\Controllers\Admin\ConditionalOrderController::class, 'table']); Route::post('conditional_orders', [\App\Http\Controllers\Admin\ConditionalOrderController::class, 'store']); diff --git a/routes/customer.php b/routes/customer.php index ed49ce1..7bb0c7d 100644 --- a/routes/customer.php +++ b/routes/customer.php @@ -5,6 +5,7 @@ use App\Http\Controllers\Customer\OrderController; use App\Http\Controllers\Customer\AddressController; use App\Http\Controllers\Customer\WalletController; use App\Http\Controllers\Customer\PriceTriggerController; +use App\Http\Controllers\Customer\AppNotificationController; use Illuminate\Support\Facades\Route; use App\Http\Controllers\Single\BankAccountController; use \App\Http\Controllers\Customer\FundController; @@ -49,6 +50,11 @@ Route::middleware(['auth:customer', 'customer.active'])->group(function () use ( //---------PriceTrigger Route::resource('price_triggers', PriceTriggerController::class); + //---------AppNotifications + Route::get('app_notifications', [AppNotificationController::class, 'index']); + Route::get('app_notifications/unread-count', [AppNotificationController::class, 'unreadCount']); + Route::post('app_notifications/{id}/read', [AppNotificationController::class, 'markRead']); + Route::post('app_notifications/read-all', [AppNotificationController::class, 'markAllRead']); //---------ConditionalOrder Route::get('conditional_orders', [\App\Http\Controllers\Customer\ConditionalOrderController::class, 'index']); Route::post('conditional_orders', [\App\Http\Controllers\Customer\ConditionalOrderController::class, 'store']);