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]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('bank_data', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->text('address')->nullable();
|
||||
$table->string('village_code')->nullable();
|
||||
$table->string('district_code')->nullable();
|
||||
$table->string('city_code')->nullable();
|
||||
$table->string('province_code')->nullable();
|
||||
$table->integer('tahun')->nullable();
|
||||
$table->decimal('luas_tanah', 15, 2)->nullable();
|
||||
$table->decimal('luas_bangunan', 15, 2)->nullable();
|
||||
$table->integer('tahun_bangunan')->nullable();
|
||||
$table->string('status_nara_sumber')->nullable();
|
||||
$table->decimal('harga', 15, 2)->nullable();
|
||||
$table->decimal('harga_diskon', 15, 2)->nullable();
|
||||
$table->decimal('diskon', 5, 2)->nullable();
|
||||
$table->decimal('total', 15, 2)->nullable();
|
||||
$table->string('nama_nara_sumber')->nullable();
|
||||
$table->string('peruntukan')->nullable();
|
||||
$table->string('penawaran')->nullable();
|
||||
$table->string('telepon')->nullable();
|
||||
$table->string('hak_properti')->nullable();
|
||||
$table->decimal('kordinat_lat', 10, 8)->nullable();
|
||||
$table->decimal('kordinat_lng', 11, 8)->nullable();
|
||||
$table->string('jenis_aset')->nullable();
|
||||
$table->string('foto_objek')->nullable();
|
||||
$table->date('tanggal')->nullable();
|
||||
$table->decimal('harga_penawaran', 15, 2)->nullable();
|
||||
$table->string('nomor_laporan')->nullable();
|
||||
$table->date('tgl_final_laporan')->nullable();
|
||||
$table->decimal('nilai_pasar', 15, 2)->nullable();
|
||||
$table->decimal('indikasi_nilai_likuidasi', 15, 2)->nullable();
|
||||
$table->decimal('indikasi_nilai_pasar_tanah', 15, 2)->nullable();
|
||||
$table->decimal('estimasi_harga_tanah', 15, 2)->nullable();
|
||||
$table->decimal('estimasi_harga_bangunan', 15, 2)->nullable();
|
||||
$table->decimal('indikasi_nilai_pasar_bangunan', 15, 2)->nullable();
|
||||
$table->decimal('indikasi_nilai_pasar_sarana_pelengkap', 15, 2)->nullable();
|
||||
$table->decimal('indikasi_nilai_pasar_mesin', 15, 2)->nullable();
|
||||
$table->decimal('indikasi_nilai_pasar_kendaraan_alat_berat', 15, 2)->nullable();
|
||||
$table->json('photos')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->unsignedBigInteger('updated_by')->nullable();
|
||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('bank_data');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user