Exemplo n.º 1
0
 public function postDestroy()
 {
     $product_image = ProductImage::find(Input::get('id'));
     if ($product_image) {
         File::delete('img/products/' . $product_image->url);
         File::delete('img/products/thumb/' . $product_image->url);
         $product_image->delete();
         return Redirect::back();
     }
     return Redirect::back()->with('message', 'Ошибка удаления');
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProductImage::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, 'last_update' => $this->last_update, 'product_id' => $this->product_id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProductImage::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('product');
     $query->andFilterWhere(['product_image_id' => $this->product_image_id, 'flag_cover' => $this->flag_cover, 'position' => $this->position, 'flag_active' => $this->flag_active, 'date_added' => $this->date_added, 'date_update' => $this->date_update]);
     $query->andFilterWhere(['like', 'product_name', $this->product_id])->andFilterWhere(['like', 'thumb_url', $this->thumb_url])->andFilterWhere(['like', 'mid_size_url', $this->mid_size_url])->andFilterWhere(['like', 'ori_size_url', $this->ori_size_url]);
     return $dataProvider;
 }
 /**
  * Fungsi untuk menghapus gambar produk
  * @param  [type] $id [description]
  * @return [type]     [description]
  */
 public function destroy($id)
 {
     $product_image = ProductImage::find($id);
     if ($product_image) {
         $product = Product::find($product_image->product_id);
         $supplier = $product->supplier;
         $config = config('amtekcommerce.product_image');
         $upload_dir = $config['dir'] . '/sup_' . $supplier->id;
         $deleteImage = unlink($upload_dir . '/' . $product_image->name);
         if ($deleteImage) {
             if ($product_image->delete()) {
                 return ['status' => 'success', 'message' => 'Gambar produk berhasil dihapus.'];
             } else {
                 return ['status' => 'failed', 'message' => 'Data Gambar tidak berhasil dihapus.'];
             }
         } else {
             return ['status' => 'failed', 'message' => 'Gambar produk tidak berhasil dihapus.'];
         }
     } else {
         return ['status' => 'failed', 'message' => 'Gambar produk tidak tersedia.'];
     }
 }
 public function actionProductview($id)
 {
     $product = Product::findOne($id);
     $productImages = ProductImage::find()->where(['product_id' => $id])->orderBy('id DESC')->all();
     return $this->render('//Frontend/ProductView', ['product' => $product, 'productImages' => $productImages]);
 }