Skip to content

Commit 45da2cc

Browse files
Working on FCM push notification
1 parent 22b0894 commit 45da2cc

27 files changed

+3138
-3
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
}
2323
},
2424
"require": {
25+
"google/auth": "^1.28"
2526
},
2627
"require-dev": {
2728
"knuckleswtf/scribe": "^5.0",
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class () extends Migration {
8+
public function up(): void
9+
{
10+
if (Schema::hasTable('device_tokens')) {
11+
return;
12+
}
13+
14+
Schema::create('device_tokens', function (Blueprint $table): void {
15+
$table->id();
16+
$table->string('token')->unique();
17+
$table->string('platform')->nullable(); // ios, android
18+
$table->string('app_version')->nullable();
19+
$table->string('device_id')->nullable();
20+
$table->string('user_type')->nullable(); // customer, admin, etc.
21+
$table->unsignedBigInteger('user_id')->nullable();
22+
$table->boolean('is_active')->default(true);
23+
$table->timestamp('last_used_at')->nullable();
24+
$table->timestamps();
25+
26+
$table->index(['user_type', 'user_id']);
27+
$table->index(['platform', 'is_active']);
28+
$table->index('is_active');
29+
});
30+
}
31+
32+
public function down(): void
33+
{
34+
Schema::dropIfExists('device_tokens');
35+
}
36+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class () extends Migration {
8+
public function up(): void
9+
{
10+
if (Schema::hasTable('push_notifications')) {
11+
return;
12+
}
13+
14+
Schema::create('push_notifications', function (Blueprint $table): void {
15+
$table->id();
16+
$table->string('title');
17+
$table->text('message');
18+
$table->string('type')->default('general'); // general, order, promotion, system, etc.
19+
$table->string('target_type')->nullable(); // all, platform, user_type, user
20+
$table->string('target_value')->nullable(); // android/ios, customer/admin, user_id
21+
$table->string('action_url')->nullable();
22+
$table->string('image_url')->nullable();
23+
$table->json('data')->nullable(); // Additional custom data
24+
$table->string('status')->default('sent'); // sent, failed, scheduled
25+
$table->integer('sent_count')->default(0);
26+
$table->integer('failed_count')->default(0);
27+
$table->integer('delivered_count')->default(0);
28+
$table->integer('read_count')->default(0);
29+
$table->timestamp('scheduled_at')->nullable();
30+
$table->timestamp('sent_at')->nullable();
31+
$table->unsignedBigInteger('created_by')->nullable(); // Admin who sent the notification
32+
$table->timestamps();
33+
34+
$table->index(['type', 'created_at']);
35+
$table->index(['status', 'scheduled_at']);
36+
$table->index('created_by');
37+
});
38+
}
39+
40+
public function down(): void
41+
{
42+
Schema::dropIfExists('push_notifications');
43+
}
44+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class () extends Migration {
8+
public function up(): void
9+
{
10+
if (Schema::hasTable('push_notification_recipients')) {
11+
return;
12+
}
13+
14+
Schema::create('push_notification_recipients', function (Blueprint $table): void {
15+
$table->id();
16+
$table->unsignedBigInteger('push_notification_id');
17+
$table->string('user_type'); // customer, admin, etc.
18+
$table->unsignedBigInteger('user_id');
19+
$table->string('device_token')->nullable(); // The specific device token used
20+
$table->string('platform')->nullable(); // android, ios
21+
$table->string('status')->default('sent'); // sent, delivered, failed, read
22+
$table->timestamp('sent_at')->nullable();
23+
$table->timestamp('delivered_at')->nullable();
24+
$table->timestamp('read_at')->nullable();
25+
$table->timestamp('clicked_at')->nullable();
26+
$table->json('fcm_response')->nullable(); // FCM response data
27+
$table->string('error_message')->nullable();
28+
$table->timestamps();
29+
30+
$table->foreign('push_notification_id')->references('id')->on('push_notifications')->onDelete('cascade');
31+
$table->index(['push_notification_id', 'user_type', 'user_id'], 'pnr_notification_user_index');
32+
$table->index(['user_type', 'user_id', 'status'], 'pnr_user_status_index');
33+
$table->index(['user_type', 'user_id', 'read_at'], 'pnr_user_read_index');
34+
$table->index('status', 'pnr_status_index');
35+
});
36+
}
37+
38+
public function down(): void
39+
{
40+
Schema::dropIfExists('push_notification_recipients');
41+
}
42+
};

public/js/api-settings.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)