Log   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 17
dl 0
loc 39
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tableName() 0 3 1
A rules() 0 10 1
A find() 0 3 1
1
<?php
2
namespace common\models;
3
4
use yii\db\ActiveRecord;
5
6
/**
7
 * This is the model class for table "logs".
8
 *
9
 * @property int $id
10
 * @property string $user
11
 * @property int $user_ip
12
 * @property int $item_type
13
 * @property int $item_id
14
 * @property string $action
15
 * @property string $old_data
16
 * @property string $new_data
17
 * @property integer $log_date
18
 */
19
class Log extends ActiveRecord
20
{
21
    const ACTION_OTHER = 0;
22
    const ACTION_CREATE = 1;
23
    const ACTION_UPDATE = 2;
24
    const ACTION_DELETE = 3;
25
26
    const ENTITY_UNKNOWN = 0;
27
    const ENTITY_USER = 1;
28
29
    /**
30
     * @inheritdoc
31
     */
32
    public static function tableName()
33
    {
34
        return '{{%logs}}';
35
    }
36
37
    /**
38
     * @return query\LogQuery
39
     */
40
    public static function find()
41
    {
42
        return new query\LogQuery(get_called_class());
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48
    public function rules()
49
    {
50
        return [
51
            [['item_type', 'item_id', 'action'], 'required'],
52
            [['item_type', 'item_id', 'action', 'user_ip'], 'integer'],
53
            [['old_data', 'new_data'], 'string'],
54
            [['user', 'old_data', 'new_data'], 'default', 'value' => ''],
55
            [['user_ip'], 'default', 'value' => 0],
56
            [['log_date'], 'default', 'value' => function () {
57
                return time();
58
            }],
59
        ];
60
    }
61
}
62