Example #1
0
 public function actionDelete($id)
 {
     $productType = \app\models\ProductType::find()->where(['id' => $id])->one();
     if (!empty($productType)) {
         if ($productType->delete()) {
             return $this->redirect(['index']);
         }
     }
 }
Example #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(ProductTypeRequest $request, $id)
 {
     $product_type = ProductType::findOrFail($id);
     $product_type->title = $request->input('title');
     $product_type->status = $request->input('status');
     $product_type->updated_at = time();
     $product_type->updated_by = Auth::user()->id;
     $product_type->update();
     Session()->flash('flash_message', 'Data has been Updated');
     return redirect('product_types');
 }
Example #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProductType::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', 'product_type', $this->product_type]);
     return $dataProvider;
 }
Example #4
0
 public function add()
 {
     $prod_types = [];
     $prodTy = ProductType::get(['id', 'type'])->toArray();
     foreach ($prodTy as $prodT) {
         $prod_types[$prodT['id']] = $prodT['type'];
     }
     $attr_sets = [];
     $attrS = AttributeSet::get(['id', 'attr_set'])->toArray();
     foreach ($attrS as $attr) {
         $attr_sets[$attr['id']] = $attr['attr_set'];
     }
     $action = route("admin.products.save");
     return view(Config('constants.adminProductView') . '.add', compact('prod_types', 'attr_sets', 'action'));
 }
 public function getFormEdit($id)
 {
     $data = array();
     $input = Product::find($id);
     if (is_null($input)) {
         return Redirect::route('admin.product');
     }
     $categories = ProductType::get();
     $data['action'] = "Edit";
     $data['input'] = Input::old();
     if (!$data['input']) {
         $data['input'] = $input;
     } else {
         $data['input']['image'] = $input['image'];
     }
     $data['category'] = $categories;
     $data['formProcess'] = "editProcess";
     return View::make('admin.site.form.product', $data);
 }
Example #6
0
 public function add()
 {
     $prod_types = [];
     $prodTy = ProductType::get(['id', 'type'])->toArray();
     foreach ($prodTy as $prodT) {
         $prod_types[$prodT['id']] = $prodT['type'];
     }
     $attr_sets = [];
     $attrS = AttributeSet::get(['id', 'attr_set'])->toArray();
     foreach ($attrS as $attr) {
         $attr_sets[$attr['id']] = $attr['attr_set'];
     }
     //
     //        $brandCats = [];
     //        $brands = Category::findBySlug("brand-name")->getDescendants(1, ['id', 'category'])->toHierarchy()->toArray();
     //        foreach ($brands as $brand) {
     //            $brandCats[$brand['id']] = $brand['category'];
     //        }
     $action = route("admin.products.save");
     return view(Config('constants.adminProductView') . '.add', compact('prod_types', 'attr_sets', 'action'));
 }
Example #7
0
 protected function fakeProductType()
 {
     $fakeProductType = new ProductType();
     $fakeProductType->product_type_name = "Fake Product Type";
     $fakeProductType->save();
     return $fakeProductType;
 }
Example #8
0
 public function getProductType()
 {
     return $this->hasOne(ProductType::className(), ['id' => 'product_type_id']);
 }
Example #9
0
    ?>
><?php 
    echo $ch2->changwat_name;
    ?>
</option>
                                            <?php 
}
?>
                                </select>
                            </div>
                            <div class="col-sm-4 col-md-4 col-lg-4">
                                ประเภทสินค้า
                                <select id="product_type" class="form-control">
                                    <option value=""> == ประเภทสินค้า ==</option>
                                    <?php 
$product_type = \app\models\ProductType::find()->all();
foreach ($product_type as $Ptype) {
    ?>
                                        <option value="<?php 
    echo $Ptype['id'];
    ?>
" <?php 
    if ($assign['product_type'] == $Ptype->id) {
        echo "selected";
    }
    ?>
><?php 
    echo $Ptype->product_type;
    ?>
</option>
                                            <?php 
 /**
  * Finds the ProductType model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ProductType the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ProductType::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function index()
 {
     $products = Product::paginate(Config::get('common.pagination'));
     $types = ProductType::where('status', 1)->lists('title', 'id');
     return view('productStockInitializations.index', compact('products', 'types'));
 }
Example #12
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $product = Product::findOrFail($id);
     $product_types = ProductType::lists('title', 'id');
     $color = Material::where('type', 3)->lists('name', 'id');
     return view('products.edit', compact('product', 'product_types', 'color'));
 }