33 lines
985 B
PHP
33 lines
985 B
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('transaksi', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->enum('jenis', ['penjualan', 'pembelian']); // Jenis transaksi
|
|
$table->foreignId('produk_id')->constrained('produk')->cascadeOnDelete(); // Relasi ke produk
|
|
$table->foreignId('lokasi_id')->constrained('lokasi')->cascadeOnDelete(); // Relasi ke lokasi
|
|
$table->integer('jumlah'); // Jumlah produk yang dibeli atau dijual
|
|
$table->decimal('total_harga', 10, 2); // Total harga transaksi
|
|
$table->timestamps();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('transaksi');
|
|
}
|
|
};
|