Catalog.php
1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace app\models;
class Catalog extends \yii\db\ActiveRecord
{
public static function tableName()
{
return 'catalog';
}
static public function getCatalogs($parent_id = 0){
return self::find()->where(['parent_id'=>$parent_id])->orderBy('sort ASC')->with('childs')->all();
}
public function getChilds()
{
return $this->hasMany(self::className(), ['parent_id' => 'id'])->orderBy('sort ASC');
}
public function getParent()
{
return $this->hasOne(self::className(), ['id' => 'parent_id']);
}
public function getCatFasovka(){
return (!empty($this->fasovka_name)) ? $this->fasovka_name : 'Фасовка';
}
public function getCatType(){
return (!empty($this->type_name)) ? $this->type_name : 'Тип';
}
public function getCatBrends(){
return (!empty($this->brends_name)) ? $this->brends_name : 'Производители';
}
}