Completed
Push — master ( 630902...b2c5cd )
by Paweł
05:18
created

Favorite::behaviors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace app\models;
4
5
use Yii;
6
use yii\behaviors\TimestampBehavior;
7
use yii\helpers\ArrayHelper;
8
9
/**
10
 * This is the model class for table "favorite".
11
 *
12
 * @property int $id
13
 * @property string $label
14
 * @property string $url
15
 * @property string $created_at
16
 * @property int $user_id [int(11)]
17
 */
18
class Favorite extends \yii\db\ActiveRecord
19
{
20
    public function behaviors()
21
    {
22
        return ArrayHelper::merge(parent::behaviors(), [
23
            'time' => [
24
                'class' => TimestampBehavior::class,
25
                'updatedAtAttribute' => false,
26
            ],
27
        ]);
28
    }
29
30
    /**
31
     * @inheritdoc
32
     */
33
    public static function tableName()
34
    {
35
        return 'favorite';
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public function rules()
42
    {
43
        return [
44
            [['label', 'url'], 'required'],
45
            [['created_at'], 'safe'],
46
            [['label', 'url'], 'string', 'max' => 255],
47
            [['user_id'], 'integer'],
48
        ];
49
    }
50
51
    /**
52
     * @inheritdoc
53
     */
54
    public function attributeLabels()
55
    {
56
        return [
57
            'id' => 'ID',
58
            'label' => 'Label',
59
            'url' => 'Url',
60
            'created_at' => 'Created At',
61
        ];
62
    }
63
}
64