- BC Break: Project folder structure changed. Removed `app/main` dir. - BC Break: Core _PHP_ framework + dependencies moved into `composer.json` and are no longer part of this repo
101 lines
2.3 KiB
PHP
101 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: Exodus 4D
|
|
* Date: 15.04.2018
|
|
* Time: 20:13
|
|
*/
|
|
|
|
namespace Exodus4D\Pathfinder\Model\Pathfinder;
|
|
|
|
use DB\SQL\Schema;
|
|
|
|
|
|
class StructureStatusModel extends AbstractPathfinderModel {
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $table = 'structure_status';
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $fieldConf = [
|
|
'active' => [
|
|
'type' => Schema::DT_BOOL,
|
|
'nullable' => false,
|
|
'default' => 1,
|
|
'index' => true
|
|
],
|
|
'name' => [
|
|
'type' => Schema::DT_VARCHAR128,
|
|
'nullable' => false,
|
|
'default' => ''
|
|
],
|
|
'label' => [
|
|
'type' => Schema::DT_VARCHAR128,
|
|
'nullable' => false,
|
|
'default' => ''
|
|
],
|
|
'class' => [
|
|
'type' => Schema::DT_VARCHAR128,
|
|
'nullable' => false,
|
|
'default' => ''
|
|
],
|
|
'structures' => [
|
|
'has-many' => ['Exodus4D\Pathfinder\Model\Pathfinder\StructureModel', 'statusId']
|
|
]
|
|
];
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected static $tableData = [
|
|
[
|
|
'id' => 1,
|
|
'name' => 'unknown',
|
|
'label' => '',
|
|
'class' => 'pf-structure-status-unknown'
|
|
],
|
|
[
|
|
'id' => 2,
|
|
'name' => 'online',
|
|
'label' => 'online',
|
|
'class' => 'pf-structure-status-online'
|
|
],
|
|
[
|
|
'id' => 3,
|
|
'name' => 'offline',
|
|
'label' => 'offline',
|
|
'class' => 'pf-structure-status-offline'
|
|
]
|
|
];
|
|
|
|
/**
|
|
* get structure status data
|
|
* @return \stdClass
|
|
*/
|
|
public function getData() : \stdClass {
|
|
$statusData = (object) [];
|
|
$statusData->id = $this->_id;
|
|
$statusData->name = $this->name;
|
|
$statusData->label = $this->label;
|
|
$statusData->class = $this->class;
|
|
|
|
return $statusData;
|
|
}
|
|
|
|
/**
|
|
* get all status options
|
|
* @return \DB\CortexCollection
|
|
*/
|
|
public static function getAll(){
|
|
$query = [
|
|
'active = :active',
|
|
':active' => 1
|
|
];
|
|
|
|
return (new self())->find($query);
|
|
}
|
|
} |