Commit 38ee261d by dianc

Category Files Model

parent b2a7a2fb
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "{{%category_files}}".
*
* @property integer $id
* @property integer $category_id
* @property string $code
* @property string $type
* @property string $name
* @property integer $created_at
* @property integer $updated_at
*
* @property Category $category
*/
class CategoryFiles extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%category_files}}';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['category_id', 'code'], 'required'],
[['category_id', 'created_at', 'updated_at'], 'integer'],
[['code', 'type', 'name'], 'string', 'max' => 32],
[['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => Category::className(), 'targetAttribute' => ['category_id' => 'id']],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('app', 'ID'),
'category_id' => Yii::t('app', 'Category ID'),
'code' => Yii::t('app', 'Code'),
'type' => Yii::t('app', 'Type'),
'name' => Yii::t('app', 'Name'),
'created_at' => Yii::t('app', 'Created At'),
'updated_at' => Yii::t('app', 'Updated At'),
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getCategory()
{
return $this->hasOne(Category::className(), ['id' => 'category_id']);
}
/**
* @inheritdoc
* @return \common\models\query\CategoryFilesQuery the active query used by this AR class.
*/
public static function find()
{
return new \common\models\query\CategoryFilesQuery(get_called_class());
}
}
<?php <?php
namespace common\models; namespace common\models\query;
/** /**
* This is the ActiveQuery class for [[Category]]. * This is the ActiveQuery class for [[\common\models\CategoryFiles]].
* *
* @see Category * @see \common\models\CategoryFiles
*/ */
class CategoryQuery extends \yii\db\ActiveQuery class CategoryFilesQuery extends \yii\db\ActiveQuery
{ {
/*public function active() /*public function active()
{ {
...@@ -16,7 +16,7 @@ class CategoryQuery extends \yii\db\ActiveQuery ...@@ -16,7 +16,7 @@ class CategoryQuery extends \yii\db\ActiveQuery
/** /**
* @inheritdoc * @inheritdoc
* @return Category[]|array * @return \common\models\CategoryFiles[]|array
*/ */
public function all($db = null) public function all($db = null)
{ {
...@@ -25,7 +25,7 @@ class CategoryQuery extends \yii\db\ActiveQuery ...@@ -25,7 +25,7 @@ class CategoryQuery extends \yii\db\ActiveQuery
/** /**
* @inheritdoc * @inheritdoc
* @return Category|array|null * @return \common\models\CategoryFiles|array|null
*/ */
public function one($db = null) public function one($db = null)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment