- 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
102 lines
2.6 KiB
PHP
102 lines
2.6 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: Exodus 4D
|
|
* Date: 18.05.2018
|
|
* Time: 23:52
|
|
*/
|
|
|
|
namespace Exodus4D\Pathfinder\Model\Universe;
|
|
|
|
use DB\SQL\Schema;
|
|
|
|
class StarModel extends AbstractUniverseModel {
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $table = 'star';
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $fieldConf = [
|
|
'name' => [
|
|
'type' => Schema::DT_VARCHAR128,
|
|
'nullable' => false,
|
|
'default' => ''
|
|
],
|
|
'typeId' => [
|
|
'type' => Schema::DT_INT,
|
|
'index' => true,
|
|
'belongs-to-one' => 'Exodus4D\Pathfinder\Model\Universe\TypeModel',
|
|
'constraint' => [
|
|
[
|
|
'table' => 'type',
|
|
'on-delete' => 'SET NULL'
|
|
]
|
|
],
|
|
'validate' => 'notDry'
|
|
],
|
|
'age' => [
|
|
'type' => Schema::DT_BIGINT,
|
|
'nullable' => true,
|
|
'default' => null
|
|
],
|
|
'radius' => [
|
|
'type' => Schema::DT_BIGINT,
|
|
'nullable' => true,
|
|
'default' => null
|
|
],
|
|
'temperature' => [
|
|
'type' => Schema::DT_INT,
|
|
'nullable' => true,
|
|
'default' => null
|
|
],
|
|
'luminosity' => [
|
|
'type' => Schema::DT_FLOAT,
|
|
'nullable' => true,
|
|
'default' => null
|
|
],
|
|
'spectralClass' => [
|
|
'type' => Schema::DT_VARCHAR128,
|
|
'nullable' => true,
|
|
'default' => null
|
|
],
|
|
'system' => [
|
|
'has-one' => ['Exodus4D\Pathfinder\Model\Universe\SystemModel', 'starId']
|
|
]
|
|
];
|
|
|
|
/**
|
|
* get data
|
|
* @return \stdClass
|
|
*/
|
|
public function getData(){
|
|
$starData = (object) [];
|
|
$starData->id = $this->_id;
|
|
$starData->name = $this->typeId->name;
|
|
|
|
return $starData;
|
|
}
|
|
|
|
/**
|
|
* @param int $id
|
|
* @param string $accessToken
|
|
* @param array $additionalOptions
|
|
*/
|
|
protected function loadData(int $id, string $accessToken = '', array $additionalOptions = []){
|
|
$data = self::getF3()->ccpClient()->send('getUniverseStar', $id);
|
|
if(!empty($data)){
|
|
/**
|
|
* @var $type TypeModel
|
|
*/
|
|
$type = $this->rel('typeId');
|
|
$type->loadById($data['typeId'], $accessToken, $additionalOptions);
|
|
$data['typeId'] = $type;
|
|
|
|
$this->copyfrom($data, ['id', 'name', 'typeId', 'age', 'radius', 'temperature', 'luminosity', 'spectralClass']);
|
|
$this->save();
|
|
}
|
|
}
|
|
} |