MenuItem::getMenu()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * @link http://www.writesdown.com/
4
 * @copyright Copyright (c) 2015 WritesDown
5
 * @license http://www.writesdown.com/license/
6
 */
7
8
namespace common\models;
9
10
use Yii;
11
use yii\db\ActiveRecord;
12
13
/**
14
 * This is the model class for table "{{%menu_item}}".
15
 *
16
 * @property integer $id
17
 * @property integer $menu_id
18
 * @property string $label
19
 * @property string $url
20
 * @property string $description
21
 * @property integer $order
22
 * @property integer $parent
23
 * @property string $options
24
 *
25
 * @property Menu $menu
26
 *
27
 * @author Agiel K. Saputra <[email protected]>
28
 * @since 0.1.0
29
 */
30
class MenuItem extends ActiveRecord
31
{
32
    public $items;
33
34
    /**
35
     * @inheritdoc
36
     */
37
    public static function tableName()
38
    {
39
        return '{{%menu_item}}';
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45 View Code Duplication
    public function rules()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
    {
47
        return [
48
            [['menu_id', 'label', 'url'], 'required'],
49
            [['menu_id', 'order', 'parent'], 'integer'],
50
            [['url', 'description', 'options'], 'string'],
51
            ['label', 'string', 'max' => 255],
52
            ['url', 'string', 'max' => 255],
53
        ];
54
    }
55
56
    /**
57
     * @inheritdoc
58
     */
59
    public function attributeLabels()
60
    {
61
        return [
62
            'id' => Yii::t('writesdown', 'ID'),
63
            'menu_id' => Yii::t('writesdown', 'Menu ID'),
64
            'label' => Yii::t('writesdown', 'Label'),
65
            'url' => Yii::t('writesdown', 'URL'),
66
            'description' => Yii::t('writesdown', 'Description'),
67
            'order' => Yii::t('writesdown', 'Order'),
68
            'parent' => Yii::t('writesdown', 'Parent'),
69
            'options' => Yii::t('writesdown', 'Options'),
70
        ];
71
    }
72
73
    /**
74
     * @return \yii\db\ActiveQuery
75
     */
76
    public function getMenu()
77
    {
78
        return $this->hasOne(Menu::className(), ['id' => 'menu_id']);
79
    }
80
}
81