++ Prima versione del designer piantine + Skill grafica
This commit is contained in:
40
app/Models/TerritorioMappa.php
Normal file
40
app/Models/TerritorioMappa.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TerritorioMappa extends Model
|
||||
{
|
||||
protected $table = 'territorio_mappe';
|
||||
|
||||
protected $fillable = [
|
||||
'territorio_id',
|
||||
'geojson',
|
||||
'image_path',
|
||||
'rendered_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'rendered_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function territorio()
|
||||
{
|
||||
return $this->belongsTo(Territorio::class, 'territorio_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* La geometria decodificata (Polygon/MultiPolygon GeoJSON) o null se
|
||||
* il contenuto non è più interpretabile.
|
||||
*/
|
||||
public function geometria(): ?array
|
||||
{
|
||||
$decoded = json_decode($this->geojson, true);
|
||||
|
||||
return is_array($decoded) ? $decoded : null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user