/** * Check if dialog is exist * * @param integer $senderId * @param integer $dialogId * @return bool|PoprigunChatDialog */ public static function getDialog($senderId, $dialogId) { $dialog = PoprigunChatDialog::find()->innerJoinWith('poprigunChatUsers')->where([PoprigunChatDialog::tableName() . '.id' => $dialogId, PoprigunChatUser::tableName() . '.user_id' => $senderId])->one(); return $dialog; }