コード例 #1
0
 /**
  * Lists all FileStorageItem models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new FileStorageItemSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $dataProvider->sort = ['defaultOrder' => ['created_at' => SORT_DESC]];
     $components = \yii\helpers\ArrayHelper::map(FileStorageItem::find()->select('component')->distinct()->all(), 'component', 'component');
     $totalSize = FileStorageItem::find()->sum('size') ?: 0;
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'components' => $components, 'totalSize' => $totalSize]);
 }
コード例 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  * @throws \yii\base\InvalidParamException
  */
 public function search($params)
 {
     $query = FileStorageItem::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'size' => $this->size, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'component', $this->component])->andFilterWhere(['like', 'base_url', $this->base_url])->andFilterWhere(['like', 'path', $this->path])->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'upload_ip', $this->upload_ip]);
     return $dataProvider;
 }
コード例 #3
0
ファイル: index.php プロジェクト: rocketyang/yii2-starter-kit
?>
" class="small-box-footer">
                    <?php 
echo Yii::t('backend', 'More info');
?>
 <i class="fa fa-arrow-circle-right"></i>
                </a>
            </div>
        </div><!-- ./col -->
        <div class="col-lg-3 col-xs-6">
            <!-- small box -->
            <div class="small-box bg-red">
                <div class="inner">
                    <h3>
                        <?php 
echo FileStorageItem::find()->count();
?>
                    </h3>
                    <p>
                        <?php 
echo Yii::t('backend', 'Files in storage');
?>
                    </p>
                </div>
                <div class="icon">
                    <i class="ion ion-pie-graph"></i>
                </div>
                <a href="<?php 
echo Yii::$app->urlManager->createUrl(['/file-storage/index']);
?>
" class="small-box-footer">