Example #1
0
 public function init()
 {
     parent::init();
     switch (1) {
         case !$this->model instanceof Alerts && ($this->remoteType == null || $this->remoteId == null):
             $this->model = new Alerts();
             break;
         default:
             $this->model = $this->model instanceof Alerts ? $this->model : Alerts::find()->where(['remote_id' => $this->remoteId, 'remote_type' => $this->remoteType, 'remote_for' => $this->remoteFor, 'user_id' => \Yii::$app->user->getId()])->one();
             break;
     }
     $this->uniqid = uniqid();
     $this->options['id'] .= $this->uniqid;
     $this->options['data-ajax-method'] = 'post';
     $this->initializeMethods();
     FollowAsset::register($this->getView());
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFollowModel()
 {
     return $this->getWidgetRelationModelQuery(\nitm\widgets\models\Alerts::className(), ['remote_id' => 'id'], ['select' => ['id', 'user_id', 'remote_id', 'remote_type'], 'andWhere' => ['remote_type' => $this->isWhat(), 'user_id' => \Yii::$app->user->getId()]]);
 }