cafeg/database/migrations/2025_01_13_154705_create_promocodes_table.php
ukyo ceeddda8b8 feat.promocode 加user name
fix. 彈跳視窗在手機bug

feat.menu 使用 slug 對應 route
2025-02-05 15:12:57 +08:00

36 lines
1.3 KiB
PHP

<?php
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('promocodes', function (Blueprint $table) {
$table->id(); // 自增主鍵
$table->string('code', 8)->unique()->comment('優惠碼');
$table->decimal('discount', 8, 2)->default(100)->comment('折扣金額或百分比');
$table->enum('type', ['amount', 'percent'])->default('percent')->comment('優惠類型: 金額或百分比');
$table->integer('usage_limit')->default(1)->comment('使用次數限制');
$table->integer('used_count')->default(0)->comment('已使用次數');
$table->date('valid_from')->nullable()->comment('有效期開始');
$table->date('valid_to')->nullable()->comment('有效期結束');
$table->boolean('is_active')->default(true)->comment('是否啟用');
$table->string('give_to')->nullable()->comment('給予誰');
$table->timestamps(); // 自動生成 created_at 和 updated_at
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('promocodes');
}
};