- Tambah 13 field alamat KTP & domisili di tabel customers (nullable, aman untuk rollback) - Update model Customer: fillable & casting tanggal - ProcessCustomerDataJob: header CSV dinamis, mapping otomatis, trim value - Batch save pakai DB::transaction(), logging detail, error handling lengkap - Fleksibel untuk CSV dengan header bervariasi & backward-compatible
67 lines
1.4 KiB
PHP
67 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Modules\Webstatement\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Modules\Basicdata\Models\Branch;
|
|
|
|
class Customer extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'customer_code',
|
|
'name',
|
|
'address',
|
|
'province',
|
|
'city',
|
|
'district',
|
|
'village',
|
|
'postal_code',
|
|
'branch_code',
|
|
'date_of_birth',
|
|
'email',
|
|
'sector',
|
|
'customer_type',
|
|
'birth_incorp_date',
|
|
'home_rt',
|
|
'home_rw',
|
|
'ktp_rt',
|
|
'ktp_rw',
|
|
'local_ref',
|
|
'ktp_kelurahan',
|
|
'ktp_kecamatan',
|
|
'town_country',
|
|
'ktp_provinsi',
|
|
'post_code',
|
|
'l_dom_street',
|
|
'l_dom_rt',
|
|
'l_dom_kelurahan',
|
|
'l_dom_rw',
|
|
'l_dom_kecamatan',
|
|
'l_dom_provinsi',
|
|
'l_dom_t_country',
|
|
'l_dom_post_code'
|
|
];
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
* Mendefinisikan casting untuk field-field tertentu
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'date_of_birth' => 'date',
|
|
'birth_incorp_date' => 'date',
|
|
];
|
|
}
|
|
public function accounts(){
|
|
return $this->hasMany(Account::class, 'customer_code', 'customer_code');
|
|
}
|
|
|
|
public function branch(){
|
|
return $this->belongsTo(Branch::class, 'branch_code', 'code');
|
|
}
|
|
}
|