public function actionGetMain($id, $model)
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     /** @var File $file */
     $file = File::find()->where(['model' => $model, 'itemId' => $id, 'is_main' => File::MAIN])->one();
     if ($file) {
         return $file->id;
     }
     return 0;
 }
示例#2
0
 /**
  * @return int
  * @throws \Exception
  */
 public function getFileCount()
 {
     $count = File::find()->where(['itemId' => $this->owner->getAttribute('id'), 'model' => $this->getModule()->getShortClass($this->owner)])->count();
     return (int) $count;
 }