first commit
This commit is contained in:
59
common/models/Category.php
Executable file
59
common/models/Category.php
Executable file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "category".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string|null $name
|
||||
* @property string|null $description
|
||||
* @property string|null $slug
|
||||
*
|
||||
* @property Product[] $products
|
||||
*/
|
||||
class Category extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'category';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name', 'description', 'slug'], 'string', 'max' => 255],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'name' => 'Name',
|
||||
'description' => 'Description',
|
||||
'slug' => 'Slug',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets query for [[Products]].
|
||||
*
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getProducts()
|
||||
{
|
||||
return $this->hasMany(Product::class, ['category_id' => 'id']);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user