Update Fix

This commit is contained in:
2026-03-06 03:26:11 +07:00
commit 8090007f39
15987 changed files with 2350525 additions and 0 deletions

1
database/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.sqlite*

View File

@@ -0,0 +1,44 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}

View File

@@ -0,0 +1,32 @@
<?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('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
}
};

View File

@@ -0,0 +1,28 @@
<?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('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('password_reset_tokens');
}
};

View File

@@ -0,0 +1,32 @@
<?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('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('failed_jobs');
}
};

View File

@@ -0,0 +1,33 @@
<?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('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};

View File

@@ -0,0 +1,29 @@
<?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('lokasi', function (Blueprint $table) {
$table->id();
$table->string('kode')->unique();
$table->string('nama');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('lokasi');
}
};

View File

@@ -0,0 +1,32 @@
<?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('produk', function (Blueprint $table) {
$table->id();
$table->string('sku')->nullable();
$table->string('nama');
$table->string('barcode')->unique();
$table->unsignedBigInteger('harga_beli')->nullable();
$table->unsignedBigInteger('harga_jual');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('produk');
}
};

View File

@@ -0,0 +1,38 @@
<?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('penjualan', function (Blueprint $table) {
$table->id();
$table->string('nomor_penjualan')->unique();
$table->timestamp('waktu')->useCurrent();
$table->unsignedBigInteger('subtotal');
$table->unsignedBigInteger('diskon')->default(0);
$table->unsignedBigInteger('pajak')->default(0);
$table->unsignedBigInteger('total');
$table->string('metode_pembayaran');
$table->unsignedBigInteger('jumlah_bayar');
$table->unsignedBigInteger('kembalian')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('penjualan');
}
};

View File

@@ -0,0 +1,41 @@
<?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('pergerakan_stok', function (Blueprint $table) {
$table->id();
$table->timestamp('waktu')->useCurrent();
$table->foreignId('produk_id')->constrained('produk')->cascadeOnDelete();
$table->foreignId('dari_lokasi_id')
->nullable()
->constrained('lokasi')
->nullOnDelete();
$table->foreignId('ke_lokasi_id')
->nullable()
->constrained('lokasi')
->nullOnDelete();
$table->string('jenis');
$table->integer('jumlah');
$table->string('referensi_tipe')->nullable();
$table->unsignedBigInteger('referensi_id')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('pergerakan_stok');
}
};

View File

@@ -0,0 +1,36 @@
<?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('penjualan_barang', function (Blueprint $table) {
$table->id();
$table->foreignId('penjualan_id')
->constrained('penjualan')
->cascadeOnDelete();
$table->foreignId('produk_id')
->constrained('produk')
->cascadeOnDelete();
$table->integer('jumlah');
$table->unsignedBigInteger('harga');
$table->unsignedBigInteger('total');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('penjualan_barang');
}
};

View File

@@ -0,0 +1,33 @@
<?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('produk_unit', function ($table) {
$table->id();
$table->foreignId('produk_id')->constrained('produk')->cascadeOnDelete();
$table->string('nama_unit');
$table->integer('multiplier')->default(1);
$table->boolean('is_base')->default(false);
$table->timestamps();
$table->unique(['produk_id', 'nama_unit']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('produk_unit');
}
};

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('pergerakan_stok', function (Blueprint $table) {
if (!Schema::hasColumn('pergerakan_stok', 'unit')) {
$table->string('unit')->nullable()->after('jumlah');
}
if (!Schema::hasColumn('pergerakan_stok', 'qty_input')) {
$table->integer('qty_input')->nullable()->after('unit');
}
if (!Schema::hasColumn('pergerakan_stok', 'multiplier')) {
$table->integer('multiplier')->nullable()->after('qty_input');
}
if (!Schema::hasColumn('pergerakan_stok', 'catatan')) {
$table->string('catatan')->nullable()->after('multiplier');
}
});
}
public function down(): void
{
Schema::table('pergerakan_stok', function (Blueprint $table) {
foreach (['unit', 'qty_input', 'multiplier', 'catatan'] as $col) {
if (Schema::hasColumn('pergerakan_stok', $col)) {
$table->dropColumn($col);
}
}
});
}
};

View File

@@ -0,0 +1,32 @@
<?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');
}
};

View File

@@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('settings', function (Blueprint $table) {
$table->id();
$table->string('key')->unique();
$table->text('value')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('settings');
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('penjualan', function (Blueprint $table) {
if (!Schema::hasColumn('penjualan', 'user_id')) {
$table->foreignId('user_id')
->nullable()
->after('id')
->constrained('users')
->nullOnDelete();
}
});
}
public function down(): void
{
Schema::table('penjualan', function (Blueprint $table) {
if (Schema::hasColumn('penjualan', 'user_id')) {
$table->dropConstrainedForeignId('user_id');
}
});
}
};

View File

@@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('pegawai', function (Blueprint $table) {
$table->id();
$table->string('nama');
$table->string('jabatan')->nullable();
$table->string('telepon')->nullable();
$table->string('alamat')->nullable();
$table->boolean('is_aktif')->default(true);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('pegawai');
}
};

View File

@@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
if (!Schema::hasColumn('users', 'role')) {
$table->string('role', 20)->default('admin')->index();
}
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
if (Schema::hasColumn('users', 'role')) {
$table->dropColumn('role');
}
});
}
};

View File

@@ -0,0 +1,53 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
if (!Schema::hasColumn('users', 'nip')) {
$table->string('nip', 30)->nullable()->unique()->index();
}
if (!Schema::hasColumn('users', 'pegawai_id')) {
$table->unsignedBigInteger('pegawai_id')->nullable()->index();
}
});
if (Schema::hasColumn('users', 'pegawai_id')) {
Schema::table('users', function (Blueprint $table) {
$table->foreign('pegawai_id')->references('id')->on('pegawai')->nullOnDelete();
});
}
// Isi NIP untuk user lama agar bisa login
if (Schema::hasColumn('users', 'nip')) {
$users = DB::table('users')->whereNull('nip')->get(['id']);
foreach ($users as $u) {
$nip = 'NIP' . str_pad((string) $u->id, 6, '0', STR_PAD_LEFT);
DB::table('users')->where('id', $u->id)->update(['nip' => $nip]);
}
}
}
public function down(): void
{
if (Schema::hasColumn('users', 'pegawai_id')) {
Schema::table('users', function (Blueprint $table) {
$table->dropForeign(['pegawai_id']);
});
}
Schema::table('users', function (Blueprint $table) {
if (Schema::hasColumn('users', 'pegawai_id')) {
$table->dropColumn('pegawai_id');
}
if (Schema::hasColumn('users', 'nip')) {
$table->dropColumn('nip');
}
});
}
};

View File

@@ -0,0 +1,62 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('pegawai', function (Blueprint $table) {
if (!Schema::hasColumn('pegawai', 'nip')) {
$table->string('nip', 30)->nullable()->unique()->index();
}
if (!Schema::hasColumn('pegawai', 'tempat_lahir')) {
$table->string('tempat_lahir', 100)->nullable();
}
if (!Schema::hasColumn('pegawai', 'tanggal_lahir')) {
$table->date('tanggal_lahir')->nullable();
}
if (!Schema::hasColumn('pegawai', 'jenis_kelamin')) {
$table->string('jenis_kelamin', 10)->nullable();
}
if (!Schema::hasColumn('pegawai', 'kota')) {
$table->string('kota', 100)->nullable();
}
if (!Schema::hasColumn('pegawai', 'nik')) {
$table->string('nik', 30)->nullable()->unique()->index();
}
if (!Schema::hasColumn('pegawai', 'foto')) {
$table->string('foto')->nullable();
}
});
}
public function down(): void
{
Schema::table('pegawai', function (Blueprint $table) {
if (Schema::hasColumn('pegawai', 'foto')) {
$table->dropColumn('foto');
}
if (Schema::hasColumn('pegawai', 'nik')) {
$table->dropColumn('nik');
}
if (Schema::hasColumn('pegawai', 'kota')) {
$table->dropColumn('kota');
}
if (Schema::hasColumn('pegawai', 'jenis_kelamin')) {
$table->dropColumn('jenis_kelamin');
}
if (Schema::hasColumn('pegawai', 'tanggal_lahir')) {
$table->dropColumn('tanggal_lahir');
}
if (Schema::hasColumn('pegawai', 'tempat_lahir')) {
$table->dropColumn('tempat_lahir');
}
if (Schema::hasColumn('pegawai', 'nip')) {
$table->dropColumn('nip');
}
});
}
};

View File

@@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('produk', function (Blueprint $table) {
if (!Schema::hasColumn('produk', 'is_aktif')) {
$table->boolean('is_aktif')->default(true)->after('harga_jual');
}
});
}
public function down(): void
{
Schema::table('produk', function (Blueprint $table) {
if (Schema::hasColumn('produk', 'is_aktif')) {
$table->dropColumn('is_aktif');
}
});
}
};

View File

@@ -0,0 +1,32 @@
<?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('vouchers', function (Blueprint $table) {
$table->id();
$table->string('kode')->unique();
$table->unsignedBigInteger('saldo')->default(0);
$table->boolean('aktif')->default(true);
$table->string('catatan', 255)->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('vouchers');
}
};

View File

@@ -0,0 +1,44 @@
<?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::table('penjualan', function (Blueprint $table) {
if (!Schema::hasColumn('penjualan', 'status_pembayaran')) {
$table->string('status_pembayaran')->default('LUNAS')->after('metode_pembayaran');
}
if (!Schema::hasColumn('penjualan', 'sisa_piutang')) {
$table->unsignedBigInteger('sisa_piutang')->default(0)->after('kembalian');
}
if (!Schema::hasColumn('penjualan', 'voucher_kode')) {
$table->string('voucher_kode')->nullable()->after('metode_pembayaran');
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('penjualan', function (Blueprint $table) {
if (Schema::hasColumn('penjualan', 'status_pembayaran')) {
$table->dropColumn('status_pembayaran');
}
if (Schema::hasColumn('penjualan', 'sisa_piutang')) {
$table->dropColumn('sisa_piutang');
}
if (Schema::hasColumn('penjualan', 'voucher_kode')) {
$table->dropColumn('voucher_kode');
}
});
}
};

View File

@@ -0,0 +1,40 @@
<?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('voucher_histories', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('voucher_id');
$table->string('kode');
$table->string('tipe'); // USE | TOPUP
$table->unsignedBigInteger('jumlah');
$table->unsignedBigInteger('saldo_before')->default(0);
$table->unsignedBigInteger('saldo_after')->default(0);
$table->unsignedBigInteger('penjualan_id')->nullable();
$table->unsignedBigInteger('user_id')->nullable();
$table->string('catatan', 255)->nullable();
$table->timestamps();
$table->index(['voucher_id']);
$table->index(['kode']);
$table->index(['tipe']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('voucher_histories');
}
};

View File

@@ -0,0 +1,37 @@
<?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('piutang_payments', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('penjualan_id');
$table->unsignedBigInteger('jumlah');
$table->string('metode')->default('CASH');
$table->string('catatan', 255)->nullable();
$table->unsignedBigInteger('user_id')->nullable();
$table->unsignedBigInteger('sisa_before')->default(0);
$table->unsignedBigInteger('sisa_after')->default(0);
$table->timestamps();
$table->index(['penjualan_id']);
$table->index(['user_id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('piutang_payments');
}
};

View File

@@ -0,0 +1,32 @@
<?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::table('penjualan', function (Blueprint $table) {
if (!Schema::hasColumn('penjualan', 'unit_piutang')) {
$table->string('unit_piutang', 100)->nullable()->after('voucher_kode');
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('penjualan', function (Blueprint $table) {
if (Schema::hasColumn('penjualan', 'unit_piutang')) {
$table->dropColumn('unit_piutang');
}
});
}
};

View File

@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('vouchers', function (Blueprint $table) {
$table->unsignedBigInteger('pegawai_id')->nullable()->after('id');
$table->index('pegawai_id', 'vouchers_pegawai_id_idx');
});
}
public function down(): void
{
Schema::table('vouchers', function (Blueprint $table) {
$table->dropIndex('vouchers_pegawai_id_idx');
$table->dropColumn('pegawai_id');
});
}
};

View File

@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('penjualan', function (Blueprint $table) {
$table->unsignedInteger('voucher_amount')->default(0)->after('voucher_kode');
});
}
public function down(): void
{
Schema::table('penjualan', function (Blueprint $table) {
$table->dropColumn('voucher_amount');
});
}
};

View File

@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('distributors', function (Blueprint $table) {
$table->id();
$table->string('nama', 150);
$table->string('alamat', 255)->nullable();
$table->string('telepon', 50)->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('distributors');
}
};

View File

@@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('penerimaan_barang', function (Blueprint $table) {
$table->id();
$table->string('nomor_penerimaan', 50)->unique();
$table->string('no_faktur', 100)->nullable();
$table->date('tanggal_faktur')->nullable();
$table->date('tanggal_datang')->nullable();
$table->foreignId('distributor_id')->constrained('distributors');
$table->foreignId('lokasi_id')->constrained('lokasi');
$table->foreignId('user_id')->constrained('users');
$table->string('status', 20)->default('DRAFT');
$table->text('catatan')->nullable();
$table->timestamp('applied_at')->nullable();
$table->timestamps();
});
Schema::create('penerimaan_barang_items', function (Blueprint $table) {
$table->id();
$table->foreignId('penerimaan_id')->constrained('penerimaan_barang')->cascadeOnDelete();
$table->foreignId('produk_id')->constrained('produk');
$table->foreignId('unit_id')->nullable()->constrained('produk_unit');
$table->unsignedInteger('qty');
$table->unsignedInteger('qty_input')->default(1);
$table->unsignedInteger('harga')->nullable();
$table->string('unit', 20)->nullable();
$table->unsignedInteger('multiplier')->default(1);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('penerimaan_barang_items');
Schema::dropIfExists('penerimaan_barang');
}
};

View File

@@ -0,0 +1,19 @@
<?php
namespace Database\Seeders;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
$this->call([
LokasiSeeder::class,
]);
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class LokasiSeeder extends Seeder
{
public function run(): void
{
DB::table('lokasi')->insert([
[
'kode' => 'GUDANG',
'nama' => 'Gudang',
'created_at' => now(),
'updated_at' => now(),
],
[
'kode' => 'TOKO',
'nama' => 'Toko',
'created_at' => now(),
'updated_at' => now(),
],
]);
}
}