add spatial plannings retribution calculations
This commit is contained in:
56
app/Models/FloorHeightIndex.php
Normal file
56
app/Models/FloorHeightIndex.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FloorHeightIndex extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'floor_number',
|
||||
'ip_ketinggian',
|
||||
'description'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'floor_number' => 'integer',
|
||||
'ip_ketinggian' => 'decimal:6'
|
||||
];
|
||||
|
||||
/**
|
||||
* Get IP ketinggian by floor number
|
||||
*/
|
||||
public static function getIpKetinggianByFloor(int $floorNumber): float
|
||||
{
|
||||
$index = self::where('floor_number', $floorNumber)->first();
|
||||
return $index ? (float) $index->ip_ketinggian : 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all IP ketinggian mapping as array
|
||||
*/
|
||||
public static function getAllMapping(): array
|
||||
{
|
||||
return self::orderBy('floor_number')
|
||||
->pluck('ip_ketinggian', 'floor_number')
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available floor numbers
|
||||
*/
|
||||
public static function getAvailableFloors(): array
|
||||
{
|
||||
return self::orderBy('floor_number')
|
||||
->pluck('floor_number')
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope: By floor number
|
||||
*/
|
||||
public function scopeByFloor($query, int $floorNumber)
|
||||
{
|
||||
return $query->where('floor_number', $floorNumber);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user