예제 #1
0
 public function anyProductDescription($product_uid)
 {
     $product = Products::where('uid', $product_uid)->first();
     $error_msg = [];
     $reviews = NULL;
     $main_image = NULL;
     if (!$product) {
         $error_msg[] = 'Sorry, product not found.';
     } else {
         $reviews = ProductReviews::where('product_id', $product->id)->where('approved', 1)->get();
         $product_main_image = ProductImages::where('product_id', $product->id)->where('is_primary', 1)->first();
         $main_image = $product_main_image->url;
     }
     return View::make('shop.product_view', ['product' => $product, 'error_msg' => $error_msg, 'reviews' => $reviews, 'main_image' => '../../../storage/app/upload/' . $main_image]);
 }
 /**
  * Deletes an existing Products model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     ProductImages::deleteAll(["product_id" => $id]);
     ProductTagProducts::deleteAll(["product_id" => $id]);
     $this->findModel($id)->delete();
     return $this->redirect(['index']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProductImage()
 {
     return $this->hasOne(ProductImages::className(), ['product_id' => 'product_id']);
 }