distribusi
This commit is contained in:
@@ -10,13 +10,13 @@ class Distribution extends Model
|
|||||||
{
|
{
|
||||||
use HasFactory, SoftDeletes;
|
use HasFactory, SoftDeletes;
|
||||||
|
|
||||||
protected $table = 'distributions';
|
protected $table = 'distribusi';
|
||||||
|
|
||||||
// Karena id adalah BIGINT auto-increment, default Laravel sudah benar (incrementing = true)
|
// Karena id adalah BIGINT auto-increment, default Laravel sudah benar (incrementing = true)
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'petani_id','panen_uid', 'nama_pengirim', 'offtaker_id', 'nama_offtaker',
|
'petani_id','panen_uid', 'nama_pengirim', 'offtaker_id', 'nama_offtaker',
|
||||||
'komoditas_id', 'berat_kg', 'grade_petani', 'grade_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',
|
'tgl_distribusi', 'tgl_terima', 'catatan', 'status',
|
||||||
'sync_status', 'created_date', 'updated_date',
|
'sync_status', 'created_date', 'updated_date',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Map;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class PanenKomoditas extends Pivot
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected $table = 'panen_komoditas';
|
||||||
|
|
||||||
|
// Penting agar ID auto-increment di tabel pivot terbaca oleh Laravel
|
||||||
|
public $incrementing = true;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'uid',
|
||||||
|
'panen_id',
|
||||||
|
'tanaman_id',
|
||||||
|
'komoditas_id',
|
||||||
|
'berat_kg',
|
||||||
|
'sync_status',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function panen(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Panen::class, 'panen_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tanaman(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Tanaman::class, 'plant_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,22 +6,23 @@ use Illuminate\Support\Facades\Schema;
|
|||||||
|
|
||||||
return new class extends Migration {
|
return new class extends Migration {
|
||||||
public function up(): void {
|
public function up(): void {
|
||||||
Schema::create('distributions', function (Blueprint $table) {
|
Schema::create('distribusi', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->unsignedBigInteger('farmer_id')->nullable();
|
$table->unsignedBigInteger('petani_id')->nullable();
|
||||||
$table->string('farmer_name')->nullable();
|
$table->unsignedBigInteger('panen_id')->nullable();
|
||||||
|
$table->string('nama_pengirim')->nullable();
|
||||||
$table->unsignedBigInteger('offtaker_id')->nullable();
|
$table->unsignedBigInteger('offtaker_id')->nullable();
|
||||||
$table->string('offtaker_name')->nullable();
|
$table->string('nama_offtaker')->nullable();
|
||||||
$table->string('commodity_name');
|
$table->string('komoditas_id');
|
||||||
$table->double('quantity_kg')->default(0);
|
$table->double('berat_kg')->default(0);
|
||||||
$table->string('farmer_grade')->nullable();
|
$table->string('grade_petani')->nullable();
|
||||||
$table->string('offtaker_grade')->nullable();
|
$table->string('grade_offtaker')->nullable();
|
||||||
$table->text('grade_difference_reason')->nullable();
|
$table->text('alasan')->nullable();
|
||||||
$table->double('price_per_kg')->default(0);
|
$table->double('harga_per_kg')->default(0);
|
||||||
$table->double('total_value')->default(0);
|
$table->double('total')->default(0);
|
||||||
$table->date('distribution_date')->nullable();
|
$table->date('tgl_distribusi')->nullable();
|
||||||
$table->date('received_date')->nullable();
|
$table->date('tgl_terima')->nullable();
|
||||||
$table->text('notes')->nullable();
|
$table->text('catatan')->nullable();
|
||||||
$table->string('status')->nullable();
|
$table->string('status')->nullable();
|
||||||
$table->string('sync_status')->default('pending');
|
$table->string('sync_status')->default('pending');
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,6 @@ return new class extends Migration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function down(): void {
|
public function down(): void {
|
||||||
Schema::dropIfExists('inspeksi_lahan');
|
Schema::dropIfExists('lahan_inspeksi');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user