parfum/database/migrations/2025_09_25_125559_create_vouchers_table.php
2025-10-03 08:09:31 +07:00

44 lines
1.5 KiB
PHP

<?php
use App\Enums\IsActive;
use App\Enums\VoucherType;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('vouchers', function (Blueprint $table) {
$table->id();
$table->string('name', 50);
$table->string('code', 20)->unique();
$table->text('terms_conditions')->nullable();
$table->enum('type', [VoucherType::values()])->default(VoucherType::PERCENTAGE)->comment(VoucherType::comment());
$table->unsignedInteger('discount_amount');
$table->unsignedInteger('min_purchase')->nullable();
$table->unsignedInteger('max_discount')->nullable();
$table->unsignedInteger('quota')->nullable();
$table->unsignedInteger('limit_per_user')->nullable();
$table->date('start_date');
$table->date('end_date')->nullable();
$table->enum('is_active', [IsActive::values()])->default(IsActive::ACTIVE)->comment(IsActive::comment());
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('vouchers');
}
};