/**
  * @inheritDoc
  */
 public static function conversations($userId)
 {
     return parent::conversations($userId)->with(['contact' => function ($contact) {
         /**@var $contact ActiveQuery * */
         $contact->with(['profile' => function ($advanced) {
             /**@var $advanced ActiveQuery * */
             $advanced->select(['id', 'CONCAT_WS(\' \', first_name, last_name) AS full_name', 'avatar']);
         }])->select(['id', 'email']);
     }]);
 }
Example #2
0
 /**
  * @inheritDoc
  */
 public static function conversations($userId)
 {
     return parent::conversations($userId)->with(['contact' => function ($contact) {
         /**@var $contact ActiveQuery * */
         $contact->with(['profile' => function ($profile) {
             /**@var $profile ActiveQuery * */
             $profile->select(['id', 'name' => new Expression('CONCAT_WS(\' \', first_name, last_name)'), 'avatar']);
         }])->select(['id']);
     }, 'newMessages' => function ($msg) use($userId) {
         /**@var $msg ActiveQuery * */
         $msg->andOnCondition(['receiver_id' => $userId])->select(['sender_id', 'count' => new Expression('COUNT(*)')]);
     }]);
 }