la_back/common/models/Category.php

60 lines
1.0 KiB
PHP
Raw Permalink Normal View History

2023-11-21 19:51:44 +03:00
<?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']);
}
}