|  |  |  | <?php
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace core\entities;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use core\entities\queries\ModuleRecordQuery;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * This is the model class for table "modules".
 | 
					
						
							|  |  |  |  *
 | 
					
						
							|  |  |  |  * @property int $id
 | 
					
						
							|  |  |  |  * @property string $name
 | 
					
						
							|  |  |  |  * @property string $class
 | 
					
						
							|  |  |  |  * @property string $type
 | 
					
						
							|  |  |  |  * @property int $active
 | 
					
						
							|  |  |  |  */
 | 
					
						
							|  |  |  | class ModuleRecord extends \yii\db\ActiveRecord
 | 
					
						
							|  |  |  | {
 | 
					
						
							|  |  |  | 	const STATUS_ENABLED = 1;
 | 
					
						
							|  |  |  | 	const STATUS_DISABLED = 0;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public $description;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * @inheritdoc
 | 
					
						
							|  |  |  |      */
 | 
					
						
							|  |  |  |     public static function tableName()
 | 
					
						
							|  |  |  |     {
 | 
					
						
							|  |  |  |         return '{{%modules}}';
 | 
					
						
							|  |  |  |     }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * @inheritdoc
 | 
					
						
							|  |  |  |      */
 | 
					
						
							|  |  |  |     public function rules()
 | 
					
						
							|  |  |  |     {
 | 
					
						
							|  |  |  |         return [
 | 
					
						
							|  |  |  |             [['name', 'class', 'type'], 'required'],
 | 
					
						
							|  |  |  |             [['name', 'class', 'type'], 'string', 'max' => 255],
 | 
					
						
							|  |  |  | 	        ['active', 'integer'],
 | 
					
						
							|  |  |  |             [['name'], 'unique'],
 | 
					
						
							|  |  |  |         ];
 | 
					
						
							|  |  |  |     }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * @inheritdoc
 | 
					
						
							|  |  |  |      */
 | 
					
						
							|  |  |  |     public function attributeLabels()
 | 
					
						
							|  |  |  |     {
 | 
					
						
							|  |  |  |         return [
 | 
					
						
							|  |  |  |             'id' => 'ID',
 | 
					
						
							|  |  |  |             'name' => 'Name',
 | 
					
						
							|  |  |  |             'class' => 'Class',
 | 
					
						
							|  |  |  |             'type' => 'Type',
 | 
					
						
							|  |  |  |         ];
 | 
					
						
							|  |  |  |     }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function isEnabled(): bool
 | 
					
						
							|  |  |  |     {
 | 
					
						
							|  |  |  |     	return $this->active == $this::STATUS_ENABLED;
 | 
					
						
							|  |  |  |     }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public function isDisabled(): bool
 | 
					
						
							|  |  |  | 	{
 | 
					
						
							|  |  |  | 		return $this->active == $this::STATUS_DISABLED;
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public static function find(): ModuleRecordQuery
 | 
					
						
							|  |  |  | 	{
 | 
					
						
							|  |  |  | 		return new ModuleRecordQuery(static::class);
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							|  |  |  | }
 |