Ejemplo n.º 1
0
 public function behaviors()
 {
     return ['timestamp' => TimestampBehavior::className(), 'event' => ['class' => EventBehavior::className(), 'events' => [ActiveRecord::EVENT_BEFORE_INSERT => function ($event) {
         $this->access_token && ($this->access_token = serialize($this->access_token));
     }, ActiveRecord::EVENT_BEFORE_UPDATE => function ($event) {
         $this->access_token && ($this->access_token = serialize($this->access_token));
     }, ActiveRecord::EVENT_AFTER_FIND => function ($event) {
         $this->access_token && ($this->access_token = unserialize($this->access_token));
     }]]];
 }
Ejemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['timestamp' => ['class' => TimestampBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['created_at']]], 'event' => ['class' => EventBehavior::className(), 'events' => [ActiveRecord::EVENT_BEFORE_INSERT => function ($event) {
         $this->message = serialize($this->message);
     }, ActiveRecord::EVENT_BEFORE_UPDATE => function ($event) {
         $this->message = serialize($this->message);
     }, ActiveRecord::EVENT_AFTER_FIND => function ($event) {
         $this->message = unserialize($this->message);
     }]]];
 }