Browse Source

ModuleRecord entity add system property

master
Egorka 6 years ago
parent
commit
7f7cd1fa89
  1. 37
      core/entities/ModuleRecord.php

37
core/entities/ModuleRecord.php

@ -4,7 +4,6 @@ namespace core\entities;
use core\entities\queries\ModuleRecordQuery; use core\entities\queries\ModuleRecordQuery;
/** /**
* This is the model class for table "modules". * This is the model class for table "modules".
* *
@ -13,13 +12,17 @@ use core\entities\queries\ModuleRecordQuery;
* @property string $class * @property string $class
* @property string $type * @property string $type
* @property int $active * @property int $active
* @property int $system
*/ */
class ModuleRecord extends \yii\db\ActiveRecord class ModuleRecord extends \yii\db\ActiveRecord
{ {
const STATUS_ENABLED = 1; const STATUS_ENABLED = 1;
const STATUS_DISABLED = 0; const STATUS_DISABLED = 0;
const SYSTEM_YES = 1;
const SYSTEM_NO = 0;
public $description; public $description;
/** /**
* @inheritdoc * @inheritdoc
@ -37,7 +40,7 @@ class ModuleRecord extends \yii\db\ActiveRecord
return [ return [
[['name', 'class', 'type'], 'required'], [['name', 'class', 'type'], 'required'],
[['name', 'class', 'type'], 'string', 'max' => 255], [['name', 'class', 'type'], 'string', 'max' => 255],
['active', 'integer'], ['active', 'integer'],
[['name'], 'unique'], [['name'], 'unique'],
]; ];
} }
@ -48,25 +51,25 @@ class ModuleRecord extends \yii\db\ActiveRecord
public function attributeLabels() public function attributeLabels()
{ {
return [ return [
'id' => 'ID', 'id' => 'ID',
'name' => 'Name', 'name' => 'Name',
'class' => 'Class', 'class' => 'Class',
'type' => 'Type', 'type' => 'Type',
]; ];
} }
public function isEnabled(): bool public function isEnabled(): bool
{ {
return $this->active == $this::STATUS_ENABLED; return $this->active == $this::STATUS_ENABLED;
} }
public function isDisabled(): bool public function isDisabled(): bool
{ {
return $this->active == $this::STATUS_DISABLED; return $this->active == $this::STATUS_DISABLED;
} }
public static function find(): ModuleRecordQuery public static function find(): ModuleRecordQuery
{ {
return new ModuleRecordQuery(static::class); return new ModuleRecordQuery(static::class);
} }
} }

Loading…
Cancel
Save