Files
sibedas/app/Models/SpatialPlanning.php
2025-06-19 13:48:35 +07:00

69 lines
1.4 KiB
PHP

<?php
namespace App\Models;
use App\Traits\HasRetributionCalculation;
use Illuminate\Database\Eloquent\Model;
/**
* Class SpatialPlanning
*
* @property $id
* @property $created_at
* @property $updated_at
* @property $name
* @property $kbli
* @property $activities
* @property $area
* @property $location
* @property $number
* @property $date
*
* @package App
* @mixin \Illuminate\Database\Eloquent\Builder
*/
class SpatialPlanning extends Model
{
use HasRetributionCalculation;
protected $perPage = 20;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = ['name', 'kbli', 'activities', 'area', 'location', 'number', 'date', 'no_tapak', 'no_skkl', 'no_ukl', 'building_function', 'sub_building_function', 'number_of_floors', 'land_area', 'site_bcr'];
protected $casts = [
'area' => 'decimal:6',
'land_area' => 'decimal:6',
'site_bcr' => 'decimal:6',
'number_of_floors' => 'integer',
'date' => 'date'
];
/**
* Get building function text for detection
*/
public function getBuildingFunctionText(): string
{
return $this->building_function ?? $this->activities ?? '';
}
/**
* Get area for calculation (prioritize area, fallback to land_area)
*/
public function getCalculationArea(): float
{
return (float) ($this->area ?? $this->land_area ?? 0);
}
}