43 lines
1.7 KiB
PHP
43 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
/**
|
|
* @property string $id
|
|
* @property string $code
|
|
* @property string $name
|
|
* @property ?string $primary_territory_id
|
|
* @property ?string $province
|
|
* @property ?string $district
|
|
* @property ?string $physical_category
|
|
* @property ?string $legal_regime
|
|
* @property ?string $development_status
|
|
* @property ?string $availability_status
|
|
* @property ?string $area_value
|
|
* @property ?string $area_unit
|
|
* @property array<int,array<string,mixed>>|null $source_evidence
|
|
*/
|
|
class InvestmentZone extends DomainRecord
|
|
{
|
|
protected $hidden = ['editorial_draft', 'operational_details'];
|
|
|
|
protected $casts = ['operational_details' => 'array', 'version_no' => 'integer', 'published_at' => 'datetime', 'aliases' => 'array', 'activities' => 'array', 'resources' => 'array', 'historical_territory' => 'array', 'area_components' => 'array', 'source_evidence' => 'array', 'area_value' => 'decimal:4', 'data_as_of' => 'date', 'sources_consulted_at' => 'date'];
|
|
|
|
/** @return BelongsTo<GeoLocation, $this> */
|
|
public function primaryTerritory(): BelongsTo
|
|
{
|
|
return $this->belongsTo(GeoLocation::class, 'primary_territory_id');
|
|
}
|
|
|
|
/** @return BelongsToMany<GeoLocation, $this> */
|
|
public function documentedLocations(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(GeoLocation::class, 'investment_zone_locations', 'zone_id', 'geo_location_id')
|
|
->withPivot(['id', 'scope_type', 'source_reference', 'legal_source_id', 'valid_from', 'valid_until', 'validation_status', 'editor_id', 'reviewer_id', 'version_no'])
|
|
->withTimestamps();
|
|
}
|
|
}
|