/**
  * Finds the TrainingCategory model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return TrainingCategory the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = TrainingCategory::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionCategory($categoryId)
 {
     $category = TrainingCategory::findOne($categoryId);
     if (empty($category)) {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
     $params = Yii::$app->request->queryParams;
     $params['categoryId'] = $categoryId;
     $searchModel = new TrainingRepository();
     $dataProvider = $searchModel->search($params);
     return $this->render(['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'categoryName' => $category->name]);
 }