add SMSpanel

This commit is contained in:
2026-07-04 11:55:10 +03:30
parent 1ce2e73ea9
commit 163097f42a
22 changed files with 6683 additions and 2214 deletions
@@ -0,0 +1,58 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('sms_wallets', function (Blueprint $table) {
$table->id();
$table->bigInteger('balance')->default(0);
$table->unsignedBigInteger('price_per_part')->default(0);
$table->boolean('is_blocked')->default(false);
$table->unsignedTinyInteger('alert_days_sent')->default(0);
$table->date('last_alert_date')->nullable();
$table->timestamps();
});
Schema::create('sms_send_logs', function (Blueprint $table) {
$table->id();
$table->string('receiver', 20);
$table->text('body');
$table->unsignedSmallInteger('parts');
$table->unsignedBigInteger('price_per_part');
$table->unsignedBigInteger('total_amount');
$table->string('provider', 64);
$table->string('source', 64)->nullable();
$table->boolean('is_alert')->default(false);
$table->timestamp('created_at')->useCurrent();
$table->index(['created_at', 'provider']);
$table->index('receiver');
});
Schema::create('sms_ledger', function (Blueprint $table) {
$table->id();
$table->string('type', 32);
$table->bigInteger('amount');
$table->bigInteger('balance_after');
$table->unsignedBigInteger('price_per_part')->nullable();
$table->unsignedSmallInteger('parts')->nullable();
$table->unsignedBigInteger('sms_send_log_id')->nullable();
$table->string('note')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->timestamp('created_at')->useCurrent();
$table->index('type');
$table->index('created_at');
});
}
public function down(): void
{
Schema::dropIfExists('sms_ledger');
Schema::dropIfExists('sms_send_logs');
Schema::dropIfExists('sms_wallets');
}
};
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
public function up(): void
{
$exists = DB::table('settings')->where('key', 'sms_panel')->exists();
if ($exists) {
return;
}
DB::table('settings')->insert([
'key' => 'sms_panel',
'value' => 'true',
'title_fa' => 'پنل پیامک (کیف پول و billing)',
'type' => 'switch',
'can_edit' => 0,
'is_active' => 1,
'created_at' => now(),
'updated_at' => now(),
]);
}
public function down(): void
{
DB::table('settings')->where('key', 'sms_panel')->delete();
}
};