feat(bank-data): tambahkan model dan migrasi untuk tabel bank_data
- Menambahkan model BankData untuk mengelola data bank. - Membuat migrasi untuk tabel bank_data dengan kolom yang diperlukan. - Menyediakan scope untuk memfilter data berdasarkan jenis aset, desa, distrik, kota, provinsi, dan tanggal.
This commit is contained in:
80
app/Models/BankData.php
Normal file
80
app/Models/BankData.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Models;
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user