public function getTicketTopic() { return $this->hasMany(TicketTopicRelation::className(), array('ticket_id' => 'ticket_id')); }
/** * 工单查看 * @param $number * @return string * @throws \yii\web\BadRequestHttpException */ public function actionDetail($number) { $ticket_detail = Ticket::find()->joinWith('cdata')->where(array('number' => $number)); $attachments = $ticket_detail->one()->file; $ticket_detail_arr = $ticket_detail->asArray()->one(); $topics = TicketTopicRelation::find()->joinWith('topic')->where(array('ticket_id' => $ticket_detail_arr['ticket_id']))->asArray()->all(); return $this->render('detail', array('ticket_detail' => $ticket_detail_arr, 'attachments' => $attachments, 'topics' => $topics)); }