84 lines
1.8 KiB
PHP
84 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: exodus4d
|
|
* Date: 17.05.15
|
|
* Time: 20:43
|
|
*/
|
|
|
|
namespace Model;
|
|
|
|
class CorporationModel extends BasicModel {
|
|
|
|
protected $table = 'corporation';
|
|
|
|
protected $fieldConf = [
|
|
'corporationCharacters' => [
|
|
'has-many' => ['Model\CharacterModel', 'allianceId']
|
|
],
|
|
'mapCorporations' => [
|
|
'has-many' => ['Model\CorporationMapModel', 'corporationId']
|
|
]
|
|
];
|
|
|
|
/**
|
|
* get all cooperation data
|
|
* @return array
|
|
*/
|
|
public function getData(){
|
|
$cooperationData = (object) [];
|
|
|
|
$cooperationData->id = $this->id;
|
|
$cooperationData->name = $this->name;
|
|
$cooperationData->sharing = $this->sharing;
|
|
|
|
|
|
return $cooperationData;
|
|
}
|
|
|
|
/**
|
|
* get all maps for this corporation
|
|
* @return array|mixed
|
|
*/
|
|
public function getMaps(){
|
|
$maps = [];
|
|
|
|
$f3 = self::getF3();
|
|
|
|
$this->filter('mapCorporations',
|
|
['active = ?', 1],
|
|
[
|
|
'limit' => $f3->get('PATHFINDER.MAX_MAPS_CORPORATION'),
|
|
'order' => 'created'
|
|
]
|
|
);
|
|
|
|
if($this->mapCorporations){
|
|
foreach($this->mapCorporations as $mapCorporation){
|
|
if($mapCorporation->mapId->isActive()){
|
|
$maps[] = $mapCorporation->mapId;
|
|
}
|
|
}
|
|
}
|
|
|
|
return $maps;
|
|
}
|
|
|
|
/**
|
|
* get all characters in this corporation
|
|
* @return array
|
|
*/
|
|
public function getCharacters(){
|
|
$characters = [];
|
|
|
|
$this->filter('corporationCharacters', ['active = ?', 1]);
|
|
|
|
if($this->corporationCharacters){
|
|
foreach($this->corporationCharacters as $character){
|
|
$characters[] = $character;
|
|
}
|
|
}
|
|
|
|
return $characters;
|
|
}
|
|
}
|