diff --git a/app/Models/Customer.php b/app/Models/Customer.php index 67e8dec..a7726d7 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -24,9 +24,13 @@ class Customer extends Model 'email', 'sector', 'customer_type', - 'birth_incorp_date' + 'birth_incorp_date', + 'home_rt', + 'home_rw', + 'ktp_rt', + 'ktp_rw', + 'local_ref' ]; - public function accounts(){ return $this->hasMany(Account::class, 'customer_code', 'customer_code'); } diff --git a/database/migrations/2025_07_10_015051_add_additional_field_to_customers_table.php b/database/migrations/2025_07_10_015051_add_additional_field_to_customers_table.php new file mode 100644 index 0000000..eb18e06 --- /dev/null +++ b/database/migrations/2025_07_10_015051_add_additional_field_to_customers_table.php @@ -0,0 +1,61 @@ +string('home_rt', 10)->nullable()->comment('RT alamat rumah'); + $table->string('home_rw', 10)->nullable()->comment('RW alamat rumah'); + + // Field RT dan RW untuk alamat KTP + $table->string('ktp_rt', 10)->nullable()->comment('RT alamat KTP'); + $table->string('ktp_rw', 10)->nullable()->comment('RW alamat KTP'); + + // Field untuk referensi lokal dengan tipe data TEXT untuk menampung data panjang + $table->text('local_ref')->nullable()->comment('Referensi lokal dengan data panjang'); + + // Menambahkan index untuk performa query jika diperlukan + $table->index(['home_rt', 'home_rw'], 'idx_customers_home_rt_rw'); + $table->index(['ktp_rt', 'ktp_rw'], 'idx_customers_ktp_rt_rw'); + }); + } + + /** + * Reverse the migrations. + * + * Menghapus field yang ditambahkan jika migration di-rollback + */ + public function down(): void + { + Schema::table('customers', function (Blueprint $table) { + // Hapus index terlebih dahulu + $table->dropIndex('idx_customers_home_rt_rw'); + $table->dropIndex('idx_customers_ktp_rt_rw'); + + // Hapus kolom yang ditambahkan + $table->dropColumn([ + 'home_rt', + 'home_rw', + 'ktp_rt', + 'ktp_rw', + 'local_ref' + ]); + }); + } +}; \ No newline at end of file