@@ 66-75 (lines=10) @@ | ||
63 | // If table not have fields, then behavior not use |
|
64 | $behaviors = []; |
|
65 | //Check timestamp |
|
66 | if ($this->hasAttribute($this->createdAtAttribute) && $this->hasAttribute($this->updatedAtAttribute)) { |
|
67 | $behaviors['timestamp'] = [ |
|
68 | 'class' => TimestampBehavior::className(), |
|
69 | 'attributes' => [ |
|
70 | ActiveRecord::EVENT_BEFORE_INSERT => [$this->createdAtAttribute, $this->updatedAtAttribute], |
|
71 | ActiveRecord::EVENT_BEFORE_UPDATE => $this->updatedAtAttribute, |
|
72 | ], |
|
73 | 'value' => new Expression('NOW()'), //TODO: need to change for different DB |
|
74 | ]; |
|
75 | } |
|
76 | ||
77 | //Check blameable |
|
78 | if ($this->hasAttribute($this->createdByAttribute) && $this->hasAttribute($this->updatedByAttribute)) { |
|
@@ 78-86 (lines=9) @@ | ||
75 | } |
|
76 | ||
77 | //Check blameable |
|
78 | if ($this->hasAttribute($this->createdByAttribute) && $this->hasAttribute($this->updatedByAttribute)) { |
|
79 | $behaviors['blameable'] = [ |
|
80 | 'class' => UserDataBehavior::className(), |
|
81 | 'attributes' => [ |
|
82 | ActiveRecord::EVENT_BEFORE_INSERT => [$this->createdByAttribute, $this->updatedByAttribute], |
|
83 | ActiveRecord::EVENT_BEFORE_UPDATE => $this->updatedByAttribute, |
|
84 | ], |
|
85 | ]; |
|
86 | } |
|
87 | ||
88 | //Check trash |
|
89 | if ($this->hasAttribute($this->removedAttribute)) { |