Esempio n. 1
0
 public function actionIndex()
 {
     $this->layout = 'home';
     $banner = new Banner();
     $listBanner = $banner->getAllBanner(7, 5);
     $dataBanner = array();
     foreach ($listBanner as $key => $value) {
         if (is_file(\Yii::$app->basePath . '\\web/assets/image/' . $value['image'])) {
             $dataBanner[] = array('title' => $value['title'], 'link' => $value['link'], 'image' => 'assets/image/' . $value['image']);
         }
     }
     $listTop = $banner->getAllBanner(9, 6);
     $dataTopBrand = array();
     foreach ($listTop as $key => $value) {
         if (is_file(\Yii::$app->basePath . '\\web/assets/image/' . $value['image'])) {
             $dataTopBrand[] = array('title' => $value['title'], 'link' => $value['link'], 'image' => 'assets/image/' . $value['image']);
         }
     }
     //get list product feature
     $module = new Module();
     $feature = new Featured();
     $setting = $module->getModule(28);
     $listFeature = $feature->getListProductFeature($setting);
     //get list product bestSeller
     $listBestSeller = $this->getBestSellerProducts();
     //get list image manufacture
     $listBannerManufacture = $banner->getAllBanner(8, 12);
     return $this->render('index', ['dataBanner' => $dataBanner, 'dataTopBrand' => $dataTopBrand, 'listFeature' => $listFeature, 'listBestSeller' => $listBestSeller, 'listBannerManufacture' => $listBannerManufacture]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Module::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'year' => $this->year, 'created_by' => $this->created_by]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Esempio n. 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getModule0()
 {
     return $this->hasOne(Module::className(), ['id' => 'module']);
 }
 /**
  * Finds the Module model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Module the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Module::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getModules()
 {
     return $this->hasMany(Module::className(), ['year' => 'id']);
 }
Esempio n. 6
0
use yii\helpers\ArrayHelper;
use yii\widgets\ActiveForm;
use frontend\models\Module;
/* @var $this yii\web\View */
/* @var $model frontend\models\File */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="file-form">

    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>

	<?php 
echo $form->field($model, 'module')->dropDownList(ArrayHelper::map(Module::find()->all(), 'id', 'name'), ['prompt' => 'Select Module']);
?>
    

    <?php 
echo $form->field($model, 'file')->fileInput();
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Upload' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();