Beispiel #1
0
 /**
  * @param null $category
  *
  * @return \yii\db\ActiveQuery
  */
 public function getCategory($category = null)
 {
     if (!$category) {
         $category = $this->category_id ? $this->category_id : 1;
     }
     return WorkCategory::findOne($category);
 }
 /**
  * Finds the WorkCategory model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return WorkCategory the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = WorkCategory::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Generates hint for file input field depending on selected category
  *
  * @param $id
  *
  * @return string
  */
 public function actionGetFileInfo($id = null)
 {
     if (!$id) {
         $id = 1;
     }
     $cat = WorkCategory::findOne($id);
     return $this->renderPartial('_file-info', ['size' => $cat->max_file_size, 'exts' => $cat->file_extensions, 'additional' => $cat->file_text]);
 }