- menyesuaikan model jika ada yang salah seperti kurangnya trait SoftDeletes, casting yang salah, relasi yang kurang dan lainnya - memperbaiki enum di migrasi
46 lines
1.6 KiB
PHP
46 lines
1.6 KiB
PHP
<?php
|
|
|
|
use App\Enums\IsShow;
|
|
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->enum('type', VoucherType::values())->default(VoucherType::PERCENTAGE)->comment(VoucherType::comment());
|
|
$table->string('tags', 20);
|
|
$table->string('summary', 200);
|
|
$table->unsignedInteger('discount_amount');
|
|
$table->unsignedInteger('min_purchase')->nullable();
|
|
$table->unsignedInteger('max_discount')->nullable();
|
|
$table->unsignedInteger('quota')->nullable();
|
|
$table->unsignedInteger('available_count')->default(0);
|
|
$table->unsignedInteger('limit_per_user')->nullable();
|
|
$table->date('start_date');
|
|
$table->date('end_date')->nullable();
|
|
$table->enum('is_show', IsShow::values())->default(IsShow::SHOW)->comment(IsShow::comment());
|
|
$table->timestamp('created_at')->useCurrent();
|
|
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();
|
|
$table->softDeletes();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('vouchers');
|
|
}
|
|
};
|