Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 37 |
| ActivityArea | |
0.00% |
0 / 1 |
|
0.00% |
0 / 7 |
56.00 | |
0.00% |
0 / 37 |
| tableName | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| behaviors | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 5 |
|||
| rules | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 9 |
|||
| attributeLabels | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 11 |
|||
| getOrganizations | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| getParent | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| getItems | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| <?php | |
| namespace common\models; | |
| use Yii; | |
| use yii\behaviors\TimestampBehavior; | |
| /** | |
| * This is the model class for table "{{%activity_area}}". | |
| * | |
| * @property integer $id | |
| * @property string $name | |
| * @property integer $created_at | |
| * @property integer $updated_at | |
| * @property integer $parent_id | |
| * | |
| * @property ActivityArea $parent | |
| * @property ActivityArea[] $items | |
| * @property Organization[] $organizations | |
| */ | |
| class ActivityArea extends \yii\db\ActiveRecord | |
| { | |
| /** | |
| * @inheritdoc | |
| */ | |
| public static function tableName() | |
| { | |
| return '{{%activity_area}}'; | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function behaviors() | |
| { | |
| return [ | |
| TimestampBehavior::className(), | |
| ]; | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function rules() | |
| { | |
| return [ | |
| [['name'], 'required'], | |
| [['parent_id'], 'integer'], | |
| [['name'], 'string', 'max' => 255], | |
| ['name', 'unique'], | |
| [['parent_id'], 'exist', 'skipOnError' => true, 'targetClass' => ActivityArea::className(), 'targetAttribute' => ['parent_id' => 'id']], | |
| ]; | |
| } | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function attributeLabels() | |
| { | |
| return [ | |
| 'id' => Yii::t('app', 'ID'), | |
| 'name' => Yii::t('app', 'Name'), | |
| 'created_at' => Yii::t('app', 'Created at'), | |
| 'updated_at' => Yii::t('app', 'Updated at'), | |
| 'parent_id' => Yii::t('app', 'Parent Activity Area'), | |
| 'parent' => Yii::t('app', 'Parent Activity Area'), | |
| 'items' => Yii::t('app', 'Child Activity Areas'), | |
| ]; | |
| } | |
| /** | |
| * @return \yii\db\ActiveQuery | |
| */ | |
| public function getOrganizations() | |
| { | |
| return $this->hasMany(Organization::className(), ['id' => 'organization_id'])->viaTable('{{%organization_activity_area}}', ['activity_area_id' => 'id']); | |
| } | |
| /** | |
| * @return \yii\db\ActiveQuery | |
| */ | |
| public function getParent() | |
| { | |
| return $this->hasOne(ActivityArea::className(), ['id' => 'parent_id']); | |
| } | |
| /** | |
| * @return \yii\db\ActiveQuery | |
| */ | |
| public function getItems() | |
| { | |
| return $this->hasMany(ActivityArea::className(), ['parent_id' => 'id']); | |
| } | |
| } |