From 871b015ce237ae8d18dfff5a65e07834b268bcb3 Mon Sep 17 00:00:00 2001 From: "fauzgabriel@gmail.com" Date: Thu, 25 Jun 2026 14:50:27 +0700 Subject: [PATCH] distribusi --- app/Models/Distribusi/Distribution.php | 4 +-- app/Models/Map/PanenKomoditas.php | 36 +++++++++++++++++++ ...04_27_092224_create_distribution_table.php | 29 +++++++-------- ...026_04_27_092226_create_inslahan_table.php | 2 +- 4 files changed, 54 insertions(+), 17 deletions(-) create mode 100644 app/Models/Map/PanenKomoditas.php diff --git a/app/Models/Distribusi/Distribution.php b/app/Models/Distribusi/Distribution.php index f280c76..3f609ab 100644 --- a/app/Models/Distribusi/Distribution.php +++ b/app/Models/Distribusi/Distribution.php @@ -10,13 +10,13 @@ class Distribution extends Model { use HasFactory, SoftDeletes; - protected $table = 'distributions'; + protected $table = 'distribusi'; // Karena id adalah BIGINT auto-increment, default Laravel sudah benar (incrementing = true) protected $fillable = [ 'petani_id','panen_uid', 'nama_pengirim', 'offtaker_id', 'nama_offtaker', 'komoditas_id', 'berat_kg', 'grade_petani', 'grade_offtaker', - 'alasan_perbedaan_grade', 'harga_per_kg', 'total', + 'alasan', 'harga_per_kg', 'total', 'tgl_distribusi', 'tgl_terima', 'catatan', 'status', 'sync_status', 'created_date', 'updated_date', ]; diff --git a/app/Models/Map/PanenKomoditas.php b/app/Models/Map/PanenKomoditas.php new file mode 100644 index 0000000..6cc538a --- /dev/null +++ b/app/Models/Map/PanenKomoditas.php @@ -0,0 +1,36 @@ +belongsTo(Panen::class, 'panen_id'); + } + + public function tanaman(): BelongsTo + { + return $this->belongsTo(Tanaman::class, 'plant_id'); + } +} diff --git a/database/migrations/2026_04_27_092224_create_distribution_table.php b/database/migrations/2026_04_27_092224_create_distribution_table.php index 7d365db..bc5b3a5 100644 --- a/database/migrations/2026_04_27_092224_create_distribution_table.php +++ b/database/migrations/2026_04_27_092224_create_distribution_table.php @@ -6,22 +6,23 @@ use Illuminate\Support\Facades\Schema; return new class extends Migration { public function up(): void { - Schema::create('distributions', function (Blueprint $table) { + Schema::create('distribusi', function (Blueprint $table) { $table->id(); - $table->unsignedBigInteger('farmer_id')->nullable(); - $table->string('farmer_name')->nullable(); + $table->unsignedBigInteger('petani_id')->nullable(); + $table->unsignedBigInteger('panen_id')->nullable(); + $table->string('nama_pengirim')->nullable(); $table->unsignedBigInteger('offtaker_id')->nullable(); - $table->string('offtaker_name')->nullable(); - $table->string('commodity_name'); - $table->double('quantity_kg')->default(0); - $table->string('farmer_grade')->nullable(); - $table->string('offtaker_grade')->nullable(); - $table->text('grade_difference_reason')->nullable(); - $table->double('price_per_kg')->default(0); - $table->double('total_value')->default(0); - $table->date('distribution_date')->nullable(); - $table->date('received_date')->nullable(); - $table->text('notes')->nullable(); + $table->string('nama_offtaker')->nullable(); + $table->string('komoditas_id'); + $table->double('berat_kg')->default(0); + $table->string('grade_petani')->nullable(); + $table->string('grade_offtaker')->nullable(); + $table->text('alasan')->nullable(); + $table->double('harga_per_kg')->default(0); + $table->double('total')->default(0); + $table->date('tgl_distribusi')->nullable(); + $table->date('tgl_terima')->nullable(); + $table->text('catatan')->nullable(); $table->string('status')->nullable(); $table->string('sync_status')->default('pending'); diff --git a/database/migrations/2026_04_27_092226_create_inslahan_table.php b/database/migrations/2026_04_27_092226_create_inslahan_table.php index 2979fd4..6d417fa 100644 --- a/database/migrations/2026_04_27_092226_create_inslahan_table.php +++ b/database/migrations/2026_04_27_092226_create_inslahan_table.php @@ -30,6 +30,6 @@ return new class extends Migration { } public function down(): void { - Schema::dropIfExists('inspeksi_lahan'); + Schema::dropIfExists('lahan_inspeksi'); } }; \ No newline at end of file