parfum/database/migrations/2025_10_01_112147_create_perfumes_table.php
Yoga Pangestu a0fd914af5 feat(perfume): crud parfum
-menambahkan skema model dan migrsai
-menyesuaikan relasi
-membuat enum Concentration
-mmebuat trait baru untuk handle category
2025-10-01 20:41:19 +07:00

41 lines
1.3 KiB
PHP

<?php
use App\Enums\Concentration;
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('perfumes', function (Blueprint $table) {
$table->id();
$table->foreignId('brand_id')->nullable()->constrained()->cascadeOnDelete();
$table->string('name', 50);
$table->string('slug', 70)->unique();
$table->string('sku', 20)->unique();
$table->enum('concentration', [Concentration::values()])->default(Concentration::EXTRAIT_DE_PERFUME)->comment(Concentration::comment());
$table->unsignedInteger('cost_price')->default(0);
$table->unsignedInteger('sale_price')->default(0);
$table->string('base_notes')->nullable();
$table->string('middle_notes')->nullable();
$table->string('top_notes')->nullable();
$table->text('description')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('perfumes');
}
};