public function rules()
{
return [
- [['name'], 'string', 'max' => 20],
+ [[ 'id' ], 'integer' ],
+ [[ 'name' ], 'string', 'max' => 100, ],
+ [[ 'name' ], 'required' ],
];
}
*
* @return \yii\db\ActiveQuery
*/
+ public function getModels()
+ {
+ return $this->hasMany(Models::className(), [ 'type_id' => 'id' ]);
+ }
+
public function getItems()
{
- return $this->hasMany(Items::className(), [ 'type_id' => 'id' ]);
+ return $this->getModels()->select(Items::tableName() . '.*')->joinWith('items');
}
}