public function actionDetail($number) { $ticket_detail = Ticket::find()->where(array('number' => $number))->one(); if (empty($ticket_detail)) { throw new BadRequestHttpException("不存在该工单"); } return $this->render('detail', array('detail' => $ticket_detail)); }
public function getFile() { return $this->hasMany(File::className(), array('attribute_id' => 'ticket_id'))->where('attribute=:table_name', array('table_name' => Ticket::tableName())); }
/** * Finds the Ticket model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Ticket the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Ticket::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php echo Html::a("我的升级工单", Yii::$app->urlManager->createUrl(array('t-center/index', 'type' => "pending"))); ?> <span class="badge"> <?php echo Ticket::find()->where(array('staff_id' => Yii::$app->user->identity->id, 'status_id' => TicketStatus::PEDDING))->count(); ?> </span> </li> <li> <?php echo Html::a("我的已完结工单", Yii::$app->urlManager->createUrl(array('t-center/index', 'type' => "finish"))); ?> <span class="badge"> <?php echo Ticket::find()->where(array('staff_id' => Yii::$app->user->identity->id, 'status_id' => TicketStatus::RESOLVED))->count(); ?> </span> </li> </ul> </div> <div> <hr/> </div> <div class="tickets"> <table class="table table-hover"> <thead> <tr> <th class="col-md-2">工单号</th> <th class="col-md-4">描述</th> <th class="col-md-2">状态</th>