Exemplo n.º 1
0
 /**
  * Deletes this notification
  */
 public function delete(\humhub\modules\user\models\User $user = null)
 {
     $condition = [];
     $condition['class'] = $this->className();
     if ($user !== null) {
         $condition['user_id'] = $user->id;
     }
     if ($this->originator !== null) {
         $condition['originator_user_id'] = $this->originator->id;
     }
     if ($this->source !== null) {
         $condition['source_pk'] = $this->source->getPrimaryKey();
         $condition['source_class'] = $this->source->className();
     }
     Notification::deleteAll($condition);
 }
Exemplo n.º 2
0
 public static function onActiveRecordDelete($event)
 {
     models\Notification::deleteAll(['source_class' => $event->sender->className(), 'source_pk' => $event->sender->getPrimaryKey()]);
 }