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 "account_note". |
11
|
|
|
* |
12
|
|
|
* @property int $id |
13
|
|
|
* @property int $account_id |
14
|
|
|
* @property int $user_id |
15
|
|
|
* @property string $note |
16
|
|
|
* @property string $created_at |
17
|
|
|
* |
18
|
|
|
* @property Account $account |
19
|
|
|
* @property User $user |
20
|
|
|
*/ |
21
|
|
|
class AccountNote extends \yii\db\ActiveRecord |
22
|
|
|
{ |
23
|
|
|
public function behaviors() |
24
|
|
|
{ |
25
|
|
|
return ArrayHelper::merge(parent::behaviors(), [ |
26
|
|
|
'time' => [ |
27
|
|
|
'class' => TimestampBehavior::class, |
28
|
|
|
'updatedAtAttribute' => false, |
29
|
|
|
], |
30
|
|
|
]); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* {@inheritdoc} |
35
|
|
|
*/ |
36
|
|
|
public static function tableName() |
37
|
|
|
{ |
38
|
|
|
return 'account_note'; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
*/ |
44
|
|
|
public function rules() |
45
|
|
|
{ |
46
|
|
|
return [ |
47
|
|
|
[['account_id', 'user_id'], 'integer'], |
48
|
|
|
[['created_at'], 'safe'], |
49
|
|
|
[['note'], 'string', 'max' => 255], |
50
|
|
|
[['account_id'], 'exist', 'skipOnError' => true, 'targetClass' => Account::class, 'targetAttribute' => ['account_id' => 'id']], |
51
|
|
|
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::class, 'targetAttribute' => ['user_id' => 'id']], |
52
|
|
|
]; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* {@inheritdoc} |
57
|
|
|
*/ |
58
|
|
|
public function attributeLabels() |
59
|
|
|
{ |
60
|
|
|
return [ |
61
|
|
|
'id' => 'ID', |
62
|
|
|
'account_id' => 'Account ID', |
63
|
|
|
'user_id' => 'User ID', |
64
|
|
|
'note' => 'Note', |
65
|
|
|
'created_at' => 'Created At', |
66
|
|
|
]; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return \yii\db\ActiveQuery |
71
|
|
|
*/ |
72
|
|
|
public function getAccount() |
73
|
|
|
{ |
74
|
|
|
return $this->hasOne(Account::class, ['id' => 'account_id']); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return \yii\db\ActiveQuery |
79
|
|
|
*/ |
80
|
|
|
public function getUser() |
81
|
|
|
{ |
82
|
|
|
return $this->hasOne(User::class, ['id' => 'user_id']); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|