Files
pathfinder/app/Model/Universe/RegionModel.php
Mark Friedrich a5f29ee2eb - NEW "Thera connections" UI module, closed #829
- Upgraded "[_pathfinder_esi_](https://github.com/exodus4d/pathfinder_esi)" Web API client`v1.3.2` → `v2.0.0`
- Fixed a js bug where current active(selected) system becomes deselected after system was dragged on map
- Fixed a js bug where new auto mapped systems (e.g. after jump) were positioned outside current map scroll viewport
- Fixed a js bug where map sync failed after map tabs switch
- Fixed blurry map when map zoom was changed
- Fixed multiple minor JS bugs where map render/update failed
2020-03-02 16:42:36 +01:00

84 lines
2.2 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: exodus4d
* Date: 29.07.17
* Time: 15:20
*/
namespace Exodus4D\Pathfinder\Model\Universe;
use DB\SQL\Schema;
class RegionModel extends AbstractUniverseModel {
/**
* @var string
*/
protected $table = 'region';
/**
* @var array
*/
protected $fieldConf = [
'name' => [
'type' => Schema::DT_VARCHAR128,
'nullable' => false,
'default' => ''
],
'description' => [
'type' => Schema::DT_TEXT
],
'constellations' => [
'has-many' => ['Exodus4D\Pathfinder\Model\Universe\ConstellationModel', 'regionId']
],
'systemNeighbours' => [
'has-many' => ['Exodus4D\Pathfinder\Model\Universe\SystemNeighbourModel', 'regionId']
]
];
/**
* get data
* @return \stdClass
*/
public function getData(){
$regionData = (object) [];
$regionData->id = $this->_id;
$regionData->name = $this->name;
return $regionData;
}
/**
* @param int $id
* @param string $accessToken
* @param array $additionalOptions
*/
protected function loadData(int $id, string $accessToken = '', array $additionalOptions = []){
$data = self::getF3()->ccpClient()->send('getUniverseRegion', $id);
if(!empty($data)){
$this->copyfrom($data, ['id', 'name', 'description']);
$this->save();
}
}
/**
* load constellations data for this region
*/
public function loadConstellationsData(){
if( !$this->dry() ){
$data = self::getF3()->ccpClient()->send('getUniverseRegion', $this->_id);
if(!empty($data)){
foreach((array)$data['constellations'] as $constellationsId){
/**
* @var $constellation ConstellationModel
*/
$constellation = $this->rel('constellations');
$constellation->loadById($constellationsId);
$constellation->reset();
}
}
}
}
}