AdPosition::getStatusList()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace zacksleo\yii2\ad\models;
4
5
use Yii;
6
use zacksleo\yii2\ad\Module;
7
8
/**
9
 * This is the model class for table "{{%ad_position}}".
10
 *
11
 * @property integer $id
12
 * @property string $name
13
 * @property string $slug
14
 * @property string $size
15
 * @property integer $status
16
 */
17
class AdPosition extends \yii\db\ActiveRecord
18
{
19
    const STATUS_ACTIVE = 1;
20
    const STATUS_INACTIVE = 0;
21
22
    /**
23
     * @inheritdoc
24
     */
25 5
    public static function tableName()
26
    {
27 5
        return '{{%ad_position}}';
28
    }
29
30
    /**
31
     * @inheritdoc
32
     */
33 5
    public function rules()
34
    {
35
        return [
36 5
            [['name', 'slug'], 'required'],
37
            ['slug', 'unique'],
38
            [['status'], 'integer'],
39
            [['name', 'slug', 'size'], 'string', 'max' => 255],
40
        ];
41
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46 1
    public function attributeLabels()
47
    {
48
        return [
49 1
            'id' => Module::t('ad', 'ID'),
50 1
            'name' => Module::t('ad', 'Name'),
51 1
            'slug' => Module::t('ad', 'Slug'),
52 1
            'size' => Module::t('ad', 'Size'),
53 1
            'status' => Module::t('ad', 'Status'),
54
        ];
55
    }
56
57
    /**
58
     * @return \yii\db\ActiveQuery
59
     */
60 1
    public function getAds()
61
    {
62 1
        return $this->hasMany(Ad::className(), ['position_id' => 'id']);
0 ignored issues
show
Deprecated Code introduced by
The method yii\base\BaseObject::className() has been deprecated with message: since 2.0.14. On PHP >=5.5, use `::class` instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
63
    }
64
65
    /**
66
     * 状态列表
67
     * @return array
68
     */
69 1
    public static function getStatusList()
70
    {
71
        return [
72 1
            self::STATUS_ACTIVE => Module::t('ad', 'Active'),
73 1
            self::STATUS_INACTIVE => Module::t('ad', 'Inactive'),
74
        ];
75
    }
76
}
77