| Total Complexity | 5 |
| Total Lines | 122 |
| Duplicated Lines | 0 % |
| Coverage | 91.3% |
| Changes | 0 | ||
| 1 | <?php |
||
| 6 | class Apps extends \Baka\Auth\Models\Apps |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * |
||
| 10 | * @var integer |
||
| 11 | */ |
||
| 12 | public $id; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | public $name; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * |
||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | public $description; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * |
||
| 28 | * @var string |
||
| 29 | */ |
||
| 30 | public $url; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * |
||
| 34 | * @var integer |
||
| 35 | */ |
||
| 36 | public $default_apps_plan_id; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * |
||
| 40 | * @var integer |
||
| 41 | */ |
||
| 42 | public $is_actived; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * |
||
| 46 | * @var string |
||
| 47 | */ |
||
| 48 | public $created_at; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * |
||
| 52 | * @var string |
||
| 53 | */ |
||
| 54 | public $updated_at; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * |
||
| 58 | * @var integer |
||
| 59 | */ |
||
| 60 | public $is_deleted; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Ecosystem default app |
||
| 64 | * @var string |
||
| 65 | */ |
||
| 66 | const GEWAER_DEFAULT_APP_NAME = 'Default'; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Initialize method for model. |
||
| 70 | */ |
||
| 71 | 29 | public function initialize() |
|
| 72 | { |
||
| 73 | 29 | parent::initialize(); |
|
| 74 | |||
| 75 | 29 | $this->setSource('apps'); |
|
| 76 | |||
| 77 | 29 | $this->hasOne( |
|
| 78 | 29 | 'default_apps_plan_id', |
|
| 79 | 29 | 'Gewaer\Models\AppsPlans', |
|
| 80 | 29 | 'id', |
|
| 81 | 29 | ['alias' => 'plan'] |
|
| 82 | ); |
||
| 83 | |||
| 84 | 29 | $this->hasMany( |
|
| 85 | 29 | 'id', |
|
| 86 | 29 | 'Gewaer\Models\AppsPlans', |
|
| 87 | 29 | 'apps_id', |
|
| 88 | 29 | ['alias' => 'plans'] |
|
| 89 | ); |
||
| 90 | |||
| 91 | 29 | } |
|
|
|
|||
| 92 | |||
| 93 | /** |
||
| 94 | * You can only get 2 variations or default in DB or the api app |
||
| 95 | * |
||
| 96 | * @param string $name |
||
| 97 | * @return Apps |
||
| 98 | */ |
||
| 99 | 14 | public static function getACLApp(string $name): Apps |
|
| 100 | { |
||
| 101 | 14 | if (trim($name) == self::GEWAER_DEFAULT_APP_NAME) { |
|
| 102 | 10 | $app = self::findFirst(0); |
|
| 103 | } else { |
||
| 104 | 4 | $app = self::findFirst(\Phalcon\DI::getDefault()->getConfig()->app->id); |
|
| 105 | } |
||
| 106 | |||
| 107 | 14 | return $app; |
|
| 108 | } |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Is active? |
||
| 112 | * |
||
| 113 | * @return boolean |
||
| 114 | */ |
||
| 115 | public function isActive(): bool |
||
| 118 | } |
||
| 119 | |||
| 120 | /** |
||
| 121 | * Returns table name mapped in the model. |
||
| 122 | * |
||
| 123 | * @return string |
||
| 124 | */ |
||
| 125 | 27 | public function getSource() : string |
|
| 128 | } |
||
| 129 | } |
||
| 130 |