Files
lpj/app/Models/BankData.php
Daeng Deni Mardaeni 992d748a2a feat(bank-data): perbarui format alamat dan tambahkan relasi lokasi
- Memperbaiki fungsi formatAlamat untuk menggunakan kode pos dari desa.
- Menambahkan relasi ke model BankData untuk desa, distrik, kota, dan provinsi.
- Memperbarui controller BankDataController untuk menyertakan alamat dalam data yang diformat.
- Memperbarui tampilan untuk menampilkan informasi alamat dengan format yang lebih baik.
2025-03-18 08:13:55 +07:00

105 lines
3.8 KiB
PHP

<?php
namespace Modules\Lpj\Models;
use Modules\Location\Models\City;
use Modules\Location\Models\District;
use Modules\Location\Models\Province;
use Modules\Location\Models\Village;
class BankData extends Base
{
protected $table = 'bank_data';
protected $guarded = ['id'];
protected $casts = [
'tahun' => 'integer',
'luas_tanah' => 'decimal:2',
'luas_bangunan' => 'decimal:2',
'tahun_bangunan' => 'integer',
'harga' => 'decimal:2',
'harga_diskon' => 'decimal:2',
'diskon' => 'decimal:2',
'total' => 'decimal:2',
'kordinat_lat' => 'decimal:8',
'kordinat_lng' => 'decimal:8',
'harga_penawaran' => 'decimal:2',
'tanggal' => 'date',
'tgl_final_laporan' => 'date',
'nilai_pasar' => 'decimal:2',
'indikasi_nilai_likuidasi' => 'decimal:2',
'indikasi_nilai_pasar_tanah' => 'decimal:2',
'estimasi_harga_tanah' => 'decimal:2',
'estimasi_harga_bangunan' => 'decimal:2',
'indikasi_nilai_pasar_bangunan' => 'decimal:2',
'indikasi_nilai_pasar_sarana_pelengkap' => 'decimal:2',
'indikasi_nilai_pasar_mesin' => 'decimal:2',
'indikasi_nilai_pasar_kendaraan_alat_berat' => 'decimal:2',
'photos' => 'array'
];
// Scope for filtering by asset type
public function scopeOfAssetType($query, $assetType)
{
return $query->where('jenis_aset', $assetType);
}
// Scope for filtering by village
public function scopeOfVillage($query, $villageCode)
{
return $query->where('village_code', $villageCode);
}
// Scope for filtering by district
public function scopeOfDistrict($query, $districtCode)
{
return $query->where('district_code', $districtCode);
}
// Scope for filtering by city
public function scopeOfCity($query, $cityCode)
{
return $query->where('city_code', $cityCode);
}
// Scope for filtering by province
public function scopeOfProvince($query, $provinceCode)
{
return $query->where('province_code', $provinceCode);
}
// Scope for filtering by date
public function scopeOfDate($query, $date)
{
return $query->whereDate('tanggal', $date);
}
// Scope for filtering by date range
public function scopeBetweenDates($query, $startDate, $endDate)
{
return $query->whereBetween('tanggal', [$startDate, $endDate]);
}
public function village()
{
return $this->belongsTo(Village::class, 'village_code', 'code');
}
public function district()
{
return $this->belongsTo(District::class, 'district_code', 'code');
}
public function city()
{
return $this->belongsTo(City::class, 'city_code', 'code');
}
public function province()
{
return $this->belongsTo(Province::class, 'province_code', 'code');
}
}