init() публичный Метод

This method is called at the end of the constructor. The default implementation will trigger an [[EVENT_INIT]] event. If you override this method, make sure you call the parent implementation at the end to ensure triggering of the event.
public init ( )
Пример #1
0
 public function init()
 {
     $modelClass = $this->modelClass;
     $tableName = $modelClass::tableName();
     //        $this->andWhere([$tableName.'.active' => 1]);
     $this->orderBy('position');
     parent::init();
 }
 public function init()
 {
     parent::init();
     /* @var $modelClass ActiveRecord */
     $modelClass = $this->modelClass;
     $tableName = $modelClass::tableName();
     $this->select(['m.id', 'm.text', 'm.created_at', 'm.is_new', 'm.sender_id'])->from(['m' => $tableName])->where(['or', ['sender_id' => $this->contactId, 'receiver_id' => $this->userId, 'is_deleted_by_receiver' => 0], ['sender_id' => $this->userId, 'receiver_id' => $this->contactId, 'is_deleted_by_sender' => 0]])->orderBy(['m.id' => SORT_DESC])->asArray();
 }
 public function init()
 {
     /**
      * @var $modelClass DpAdminMenuUrlRelation
      */
     $modelClass = $this->modelClass;
     $this->tableName = $modelClass::tableName();
     parent::init();
 }
 public function init()
 {
     parent::init();
     /* @var $modelClass ActiveRecord */
     $modelClass = $this->modelClass;
     $tableName = $modelClass::tableName();
     $subQuery = (new Query())->from($tableName)->select(['message_id' => new Expression('MAX([[id]])'), 'contact_id' => new Expression('IF([[sender_id]] = :userId, [[receiver_id]], [[sender_id]])')])->where(['or', ['receiver_id' => $this->userId, 'is_deleted_by_receiver' => 0], ['sender_id' => $this->userId, 'is_deleted_by_sender' => 0]])->params([':userId' => $this->userId])->groupBy(['contact_id']);
     $this->alias('m')->select(['c.contact_id', 'm.id', 'm.sender_id', 'm.text', 'm.created_at'])->innerJoin(['c' => $subQuery], 'c.message_id = m.id')->orderBy(['c.message_id' => SORT_DESC])->params([':userId' => $this->userId])->asArray();
 }
 public function init()
 {
     parent::init();
     /* @var $modelClass ActiveRecord */
     $modelClass = $this->modelClass;
     $tableName = $modelClass::tableName();
     $subQuery = (new Query())->from($tableName)->select(['MAX( [[id]] ) AS [[last_message_id]]', 'IF( [[sender_id]] = :userId, [[receiver_id]], [[sender_id]] ) AS [[contact_id]]'])->where(['or', ['receiver_id' => $this->userId, 'is_deleted_by_receiver' => 0], ['sender_id' => $this->userId, 'is_deleted_by_sender' => 0]])->params([':userId' => $this->userId])->groupBy(['[[contact_id]]']);
     $this->select(['contact_id', 'id', 'sender_id', 'text', 'created_at'])->from(['ms' => $subQuery])->innerJoin(['m' => $tableName], '[[last_message_id]] = [[id]]')->orderBy(['id' => SORT_DESC])->params([':userId' => $this->userId]);
 }
Пример #6
0
 public function init()
 {
     $workplace_id = null;
     if (\Yii::$app->user->can('FilterByWorkplace')) {
         $workplace_id = \Yii::$app->user->identity->workplace_id ? \Yii::$app->user->identity->workplace_id : 0;
     }
     $user_id = null;
     if (\Yii::$app->user->can('FilterByUser')) {
         $user_id = \Yii::$app->user->id ? \Yii::$app->user->id : 0;
     }
     $this->andFilterWhere(['or', ['=', 'user_id', $user_id], ['=', 'workplace_id', $workplace_id]]);
     parent::init();
 }
Пример #7
0
 /**
  * Фильтр записей с типом опыта = "Работа"
  * DefaultScope
  */
 public function init()
 {
     parent::init();
     $this->andWhere(['type_id' => 2]);
 }
Пример #8
0
 public function init()
 {
     $this->buildNoInitModel();
     parent::init();
 }
Пример #9
0
 public function init()
 {
     parent::init();
 }
Пример #10
0
 public function init()
 {
     parent::init();
     $this->type($this->contentType);
 }
Пример #11
0
 public function init()
 {
     parent::init();
     $this->alias('m');
 }
Пример #12
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     $expr = new Expression('0');
     $this->select(["{{%{$this->tableName}}}.*", 'last_message_id' => $expr]);
     parent::init();
 }
Пример #13
0
 public function init()
 {
     parent::init();
     $this->type($this->metaType);
 }
Пример #14
0
 public function init()
 {
     parent::init();
     $this->alias('c');
     $this->select(['last_message_id' => new Expression('MAX([[id]])'), 'contact_id' => new Expression('IF([[sender_id]] = :userId, [[receiver_id]], [[sender_id]])')])->andWhere(['or', ['receiver_id' => new Expression(':userId'), 'is_deleted_by_receiver' => false], ['sender_id' => new Expression(':userId'), 'is_deleted_by_sender' => false]])->groupBy(['contact_id']);
 }
Пример #15
0
 public function init()
 {
     parent::init();
     $this->alias('m')->select(['m.id', 'm.text', 'm.created_at', 'm.is_new', 'm.sender_id'])->where(['or', ['sender_id' => $this->contactId, 'receiver_id' => $this->userId, 'is_deleted_by_receiver' => 0], ['sender_id' => $this->userId, 'receiver_id' => $this->contactId, 'is_deleted_by_sender' => 0]])->orderBy(['m.id' => SORT_DESC])->asArray();
 }