コード例 #1
0
 public function actionIndex()
 {
     $data = Category::find()->all();
     $searchModel = new CategorySearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'data' => $data]);
 }
コード例 #2
0
 /**
  * Updates an existing SubCategory model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $categoriesArray = ArrayHelper::map(Category::find()->all(), 'id', 'name');
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'categoriesArray' => $categoriesArray]);
     }
 }
コード例 #3
0
ファイル: OrderController.php プロジェクト: kvaxminsk/evo8
 public function actionShowOrder($id = null)
 {
     $model = new Order();
     $model = $model::findOne(['id' => $id]);
     //var_dump($model->product_id);die();
     $products = Product::find()->asArray()->all();
     $listProducts = ArrayHelper::map($products, 'id', 'name');
     $categories = Category::find()->asArray()->all();
     $listCategories = ArrayHelper::map($categories, 'id', 'name');
     $subCategories = SubCategory::find()->asArray()->all();
     $listSubCategories = ArrayHelper::map($subCategories, 'id', 'name');
     return $this->render('showOrder', ['model' => $model, 'listProducts' => $listProducts, 'listCategories' => $listCategories, 'listSubCategories' => $listSubCategories]);
 }
コード例 #4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Category::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]);
     $query->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
コード例 #5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Category::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->joinWith('parent');
     $query->andFilterWhere(['category.id' => $this->id, 'category.parent_category_id' => $this->parent_category_id, 'category.created' => $this->created, 'category.updated' => $this->updated, 'category.active' => $this->active]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'keywords', $this->keywords])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'image', $this->image]);
     return $dataProvider;
 }
コード例 #6
0
ファイル: _form.php プロジェクト: phamviet1510/daitech-web
use app\modules\admin\models\Category;
$this->title = 'Project';
$this->params['breadcrumbs'][] = $this->title;
/* @var $this yii\web\View */
/* @var $model app\modules\admin\models\Project */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="project-form">

    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>
    
    <?php 
echo $form->field($model, 'category_id')->dropDownList([ArrayHelper::map(Category::find()->all(), 'category_id', 'name')]);
?>

    <?php 
echo $form->field($model, 'project_name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'investor')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'acreage')->textInput(['maxlength' => true]);
?>

    <?php 
コード例 #7
0
ファイル: ProductController.php プロジェクト: kvaxminsk/evo8
 /**
  * Updates an existing Product model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $modelCategory = new Category();
     $categoriesArray = ArrayHelper::map(Category::find()->all(), 'id', 'name');
     $modelLinkProduct = LinkProduct::find()->where(['id_product' => $id])->orderBy('id_category')->all();
     $subCategoriesArray = SubCategory::find()->all();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         LinkProduct::deleteAll(['id_product' => $id]);
         foreach (Yii::$app->request->post()['category'] as $key => $id) {
             //var_dump($id.'---');
             if (Yii::$app->request->post()['subCategory' . $id]) {
                 foreach (Yii::$app->request->post()['subCategory' . $id] as $keySub => $idSub) {
                     //$linkProductArray = array($model->id,$id,$idSub);
                     $modelLinkProduct = new LinkProduct();
                     //var_dump($keySub.$idSub );echo "<br>";
                     $modelLinkProduct->id_product = $model->id;
                     $modelLinkProduct->id_category = $id;
                     $modelLinkProduct->id_sub_category = $idSub;
                     $modelLinkProduct->save();
                 }
             } else {
                 $modelLinkProduct = new LinkProduct();
                 //var_dump($keySub.$idSub );echo "<br>";
                 $modelLinkProduct->id_product = $model->id;
                 $modelLinkProduct->id_category = $id;
                 $modelLinkProduct->id_sub_category = 0;
                 $modelLinkProduct->save();
             }
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         $modelLinkProduct = LinkProduct::find()->where(['id_product' => $id])->orderBy('id_category')->all();
         //            var_dump(ArrayHelper::map($modelLinkProduct,'id','id_product'));die();
         return $this->render('update', ['model' => $model, 'categoriesArray' => $categoriesArray, 'subCategoriesArray' => $subCategoriesArray, 'modelLinkProductCategory' => ArrayHelper::map($modelLinkProduct, 'id', 'id_category'), 'modelLinkProductSubCategory' => ArrayHelper::map($modelLinkProduct, 'id', 'id_sub_category')]);
     }
 }
コード例 #8
0
ファイル: _form.php プロジェクト: bysobi/blog
/* @var $model app\modules\blog\models\Post */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="post-form">

    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>
    
    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'category_id')->widget(Select2::className(), ['data' => ArrayHelper::map(Category::find()->getActive()->all(), 'id', 'title'), 'language' => 'en', 'options' => ['placeholder' => 'Select a category ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
    <?php 
echo $form->field($model, 'description')->widget(CKEditor::className(), ['options' => ['row' => 6], 'preset' => 'basic']);
?>
    <?php 
echo $form->field($model, 'text')->widget(CKEditor::className(), ['options' => ['row' => 6], 'preset' => 'basic']);
?>
    <?php 
echo $form->field($model, 'img')->widget(FileInput::classname(), ['name' => 'img[]', 'options' => ['multiple' => true], 'pluginOptions' => ['initialPreview' => $model->img ? Html::img($model->img, ['class' => 'file-preview-image']) : '', 'overwriteInitial' => true]]);
?>
    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>
コード例 #9
0
ファイル: CategoryController.php プロジェクト: kvaxminsk/evo8
 /**
  * Lists all Category models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Category::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
コード例 #10
0
ファイル: JokeController.php プロジェクト: azrapiric/vicevi
 public function getCategories()
 {
     $category = Category::find()->all();
     return $category;
 }
コード例 #11
0
ファイル: DefaultController.php プロジェクト: bysobi/blog
 /**
  * Displays a single Post model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $modelCategory = Category::find()->getActive()->all();
     return $this->render('view', ['model' => $this->findModel($id), 'modelCategory' => $modelCategory]);
 }
コード例 #12
0
ファイル: _form.php プロジェクト: aversilov/singree-bboard
use yii\helpers\ArrayHelper;
use app\modules\admin\models\Category;
use mihaildev\ckeditor\CKEditor;
?>

<div class="items-form">
    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>
    <?php 
echo $form->field($model, 'file')->fileInput();
?>
    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => 255]);
?>
    <?php 
echo $form->field($model, 'text')->widget(CKEditor::className(), ['editorOptions' => ['preset' => 'full', 'inline' => false]]);
?>
    <?php 
echo $form->field($model, 'category')->dropDownList(ArrayHelper::map(Category::find()->all(), 'title', 'title'), ['promt' => 'Выберите категорию']);
?>
    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Создать' : 'Обновить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>
    <?php 
ActiveForm::end();
?>
</div>