Files
pathfinder/app/Model/Universe/ConstellationModel.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

116 lines
3.1 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: exodus4d
* Date: 29.07.2017
* Time: 16:49
*/
namespace Exodus4D\Pathfinder\Model\Universe;
use DB\SQL\Schema;
class ConstellationModel extends AbstractUniverseModel {
/**
* @var string
*/
protected $table = 'constellation';
/**
* @var array
*/
protected $fieldConf = [
'name' => [
'type' => Schema::DT_VARCHAR128,
'nullable' => false,
'default' => ''
],
'regionId' => [
'type' => Schema::DT_INT,
'index' => true,
'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\RegionModel',
'constraint' => [
[
'table' => 'region',
'on-delete' => 'CASCADE'
]
],
'validate' => 'notDry'
],
'x' => [
'type' => Schema::DT_BIGINT,
'nullable' => false,
'default' => 0
],
'y' => [
'type' => Schema::DT_BIGINT,
'nullable' => false,
'default' => 0
],
'z' => [
'type' => Schema::DT_BIGINT,
'nullable' => false,
'default' => 0
],
'systems' => [
'has-many' => ['Exodus4D\Pathfinder\Model\Universe\SystemModel', 'constellationId']
],
'systemNeighbours' => [
'has-many' => ['Exodus4D\Pathfinder\Model\Universe\SystemNeighbourModel', 'constellationId']
]
];
/**
* get data
* @return \stdClass
*/
public function getData(){
$constellationData = (object) [];
$constellationData->id = $this->_id;
$constellationData->name = $this->name;
$constellationData->region = $this->regionId->getData();
return $constellationData;
}
/**
* @param int $id
* @param string $accessToken
* @param array $additionalOptions
*/
protected function loadData(int $id, string $accessToken = '', array $additionalOptions = []){
$data = self::getF3()->ccpClient()->send('getUniverseConstellation', $id);
if(!empty($data)){
/**
* @var $region RegionModel
*/
$region = $this->rel('regionId');
$region->loadById($data['regionId'], $accessToken, $additionalOptions);
$data['regionId'] = $region;
$this->copyfrom($data, ['id', 'name', 'regionId', 'position']);
$this->save();
}
}
/**
* load systems data for this constellation
*/
public function loadSystemsData(){
if( !$this->dry() ){
$data = self::getF3()->ccpClient()->send('getUniverseConstellation', $this->_id);
if(!empty($data)){
foreach((array)$data['systems'] as $systemId){
/**
* @var $system SystemModel
*/
$system = $this->rel('systems');
$system->loadById($systemId);
$system->reset();
}
}
}
}
}