當前位置: 首頁>>代碼示例>>PHP>>正文


PHP models\Product類代碼示例

本文整理匯總了PHP中app\models\Product的典型用法代碼示例。如果您正苦於以下問題:PHP Product類的具體用法?PHP Product怎麽用?PHP Product使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Product類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionPayment

 public function actionPayment()
 {
     if (\Yii::$app->session->has('customer')) {
         $modelCustomer = new Customer();
         $infoCustomer = $modelCustomer->getInformation($_SESSION['customer']);
         $modelOrder = new Order();
         $modelOrderDetail = new OrderDetail();
         $modelProduct = new Product();
         $ids = array();
         foreach ($_SESSION['cart_items'] as $id => $quantity) {
             array_push($ids, $id);
         }
         $products = $modelProduct->getWithIDs($ids);
         if (\Yii::$app->request->post()) {
             $modelOrder->load(\Yii::$app->request->post());
             $modelOrder->save();
             $orderId = $modelOrder->id;
             foreach ($_SESSION['cart_items'] as $id => $quantity) {
                 $unitPrice = $modelProduct->getPrice($id) * $quantity;
                 \Yii::$app->db->createCommand()->insert('order_detail', ['orderId' => $orderId, 'productId' => $id, 'unitPrice' => $unitPrice, 'quantity' => $quantity])->execute();
             }
             \Yii::$app->session->remove('cart_items');
             return $this->redirect(['cart/index', 'success' => 'Thanh toán thành công! Chúng tôi sẽ liên hệ bạn trong thời gian sớm nhất! Xin cảm ơn!']);
         } else {
             return $this->render('payment', ['infoCustomer' => $infoCustomer, 'modelOrder' => $modelOrder, 'products' => $products]);
         }
     } else {
         $this->redirect(['customer/login', 'error' => 'Vui lòng đăng nhập trước khi thanh toán']);
     }
 }
開發者ID:royutoan,項目名稱:pianodanang,代碼行數:30,代碼來源:CartController.php

示例2: updatingListProducts

 public function updatingListProducts($data)
 {
     //pr($data);
     $productModel = new Product();
     foreach ($data as $key => &$element) {
         if (isset($element['GK.site_id'])) {
             $check = $productModel->comparePrice('GK', $key, isset($element['GK.enabled']) ? $element['GK.enabled'] : null, isset($element['GK.yandex_enabled']) ? $element['GK.yandex_enabled'] : null, isset($element['GK.price']) ? addComma($element['GK.price']) : null, isset($element['GK.currency']) ? $element['GK.currency'] : null);
             if ($check) {
                 $element['GK.to_export'] = 1;
             }
         }
         if (isset($element['TV.site_id'])) {
             $check = $productModel->comparePrice('TV', $key, isset($element['TV.enabled']) ? $element['TV.enabled'] : null, isset($element['TV.yandex_enabled']) ? $element['TV.yandex_enabled'] : null, isset($element['TV.price']) ? addComma($element['TV.price']) : null, isset($element['TV.currency']) ? $element['TV.currency'] : null);
             if ($check) {
                 $element['TV.to_export'] = 1;
             }
         }
         if (isset($element['MK.site_id'])) {
             $check = $productModel->comparePrice('MK', $key, isset($element['MK.enabled']) ? $element['MK.enabled'] : null, isset($element['MK.yandex_enabled']) ? $element['MK.yandex_enabled'] : null, isset($element['MK.price']) ? addComma($element['MK.price']) : null, isset($element['MK.currency']) ? $element['MK.currency'] : null);
             if ($check) {
                 $element['MK.to_export'] = 1;
             }
         }
         $this->leftJoin('price_GK as GK', 'products.id', '=', 'GK.product_id')->leftJoin('price_TV as TV', 'products.id', '=', 'TV.product_id')->leftJoin('price_MK as MK', 'products.id', '=', 'MK.product_id')->where('products.id', $key)->update($element);
     }
     /*pr($data,true);*/
 }
開發者ID:enotsokolov,項目名稱:vp_plus,代碼行數:27,代碼來源:Product.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $pro = new Product();
     $adSlotObj = new Adslot();
     $catObj = new Category();
     $brandObj = new Brand();
     /*getting all products for all slots(currently we have 7 slots)*/
     $adSlot_data = $adSlotObj->with(['products'])->get();
     /*t1-t7*/
     // dd($adSlot_data[4]['products'][0]);
     $category_temp_data = $catObj->orderBy('created_at')->take(10)->get();
     /*f1-f10*/
     $brand_data = $brandObj->with(['products'])->get();
     $category_data = [];
     foreach ($category_temp_data as $cat_id) {
         $cat_latest_product = $pro->where('category_id', '=', $cat_id['id'])->orderBy('created_at')->take(1)->pluck('photo_1');
         $cat_latest_product_id = $pro->where('category_id', '=', $cat_id['id'])->orderBy('created_at')->take(1)->pluck('id');
         $cat_random_product = $pro->where('category_id', '=', $cat_id['id'])->orderBy(DB::raw('RAND()'))->take(6)->get();
         $cat_brands = $pro->with(['brand'])->where('category_id', '=', $cat_id['id'])->take(5)->get();
         $cat_products_random_photos = [];
         foreach ($cat_random_product as $photo) {
             $cat_products_random_photos[] = $photo;
         }
         $category_data[] = ['color' => $cat_id['color'], 'floor' => $cat_id['floor'], 'name' => $cat_id['name'], 'desc' => $cat_id['description'], 'logo' => $cat_id['logo'], 'latest_photo_id' => $cat_latest_product_id, 'latest_photo' => $cat_latest_product, 'random_photos' => $cat_products_random_photos, 'brands' => $cat_brands];
     }
     return view('landing_page', compact(['adSlot_data', 'category_data']));
 }
開發者ID:khakanali,項目名稱:OpenMAll,代碼行數:32,代碼來源:Landing.php

示例4: setUp

 public function setUp()
 {
     parent::setUp();
     $this->shared('product', function () {
         $product = new Product(["product_name" => "iPhone 6", "product_desc" => "iPhone 6", "status" => "available", "options" => [["name" => "顏色", "options" => ["深空灰", "銀色", "金色"]], ["name" => "容量", "options" => ["16GB", "64GB", "128GB"]]], "specifications" => [["attr_name" => "高度", "attr_group" => "重量和尺寸", "attr_value" => "138.1 毫米(5.44 英寸)"], ["attr_name" => "寬度", "attr_group" => "重量和尺寸", "attr_value" => "67.0 毫米 (2.64 英寸)"], ["attr_name" => "厚度", "attr_group" => "重量和尺寸", "attr_value" => "6.9 毫米 (0.27 英寸)"], ["attr_name" => "重量", "attr_group" => "重量和尺寸", "attr_value" => "129 克 (4.55 盎司)"]]]);
         $product->save();
         return $product;
     });
 }
開發者ID:kshar1989,項目名稱:dianpou,代碼行數:9,代碼來源:ProductStockTest.php

示例5: actionIndex

 public function actionIndex()
 {
     $product = new Product('jielun', 50);
     print_r($product->getProductName());
     print_r('<br>---------------<br>');
     $cdProduct = new CdProduct('jay', 20);
     print_r($cdProduct->getProductName());
     //print_r($cdProduct->getAddress());   //子類無法使用parent::$address訪問父類的私有屬性
 }
開發者ID:thegofind,項目名稱:yii2advance,代碼行數:9,代碼來源:PhpController.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Product $product, Request $request)
 {
     if ($request->ajax()) {
         $request = $request->all();
         $products = $product->filter($request, $this->itemsCount);
         $i = 1;
         return view('admin._response.products-index')->with('products', $products)->with('i', $i);
     }
 }
開發者ID:metisast,項目名稱:tiyn.local,代碼行數:15,代碼來源:ProductsController.php

示例7: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(UpdateProductRequest $request, Product $product)
 {
     $data = $request->input();
     $product->fill($data);
     $product->save();
     $this->savePhoto($product, $request);
     $product->categories()->detach($product->categories()->lists('id')->toArray());
     $product->categories()->attach($data['categories']);
     return Redirect()->route('home');
 }
開發者ID:RsanabriaZ,項目名稱:web-catalog,代碼行數:17,代碼來源:ProductController.php

示例8: findModel

 public function findModel($id)
 {
     $search = new Product();
     $search->scenario = Product::SCENARIO_READ;
     if (($model = $search->findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
開發者ID:vodas,項目名稱:praktykigda,代碼行數:10,代碼來源:ProductCRUDContainer.php

示例9: buildFromInput

 protected function buildFromInput(Product $product, $input)
 {
     $title = $input->get('title');
     // #TODO: Shouldn't really be optional
     $imageUrl = $input->has('image_url') ? $input->get('image_url') : null;
     $product->setTitle($title);
     $product->setImageUrl($imageUrl);
     EntityManager::persist($product);
     EntityManager::flush();
     return $product;
 }
開發者ID:Epoch2,項目名稱:wiwi-backend,代碼行數:11,代碼來源:ProductService.php

示例10: show

 public function show($cat, $prod = '')
 {
     !preg_match("|^[a-z0-9]+\$|", $cat) && exit;
     $prod && !preg_match("|^[a-z0-9]+\$|", $prod) && exit;
     $product = new Product();
     $view = new View();
     $cat && ($result = $product->showCatalog($cat, $prod)) ? $view->display($result, $cat) : (($result = $product->showProduct($prod)) ? $view->display($result, 'prod') : ($this->error = true));
     if ($this->error) {
         throw new Exception('Что то пошло не так... Скорее всего таблица пуста!');
     }
 }
開發者ID:awful0,項目名稱:testing,代碼行數:11,代碼來源:Controller.php

示例11: deleteProduct

 public function deleteProduct(Product $product)
 {
     event(new DeleteUnpublishedNotification($product->barcode));
     if ($product->countOrganizations == 1) {
         $product->delete();
     } else {
         $product->organizations()->detach($this->user->organization->id);
     }
     flash()->info('Διεγράφη', 'το συγκεκριμένο προϊόν διεγράφη με επιτυχία από τον Οργανισμό');
     return redirect()->route('Admin::Unpublished::index');
 }
開發者ID:nicsmyrn,項目名稱:library,代碼行數:11,代碼來源:UnpublishedController.php

示例12: actionSearchProducts

 public function actionSearchProducts()
 {
     $modelForm = new Product();
     $results = null;
     if ($modelForm->load(Yii::$app->request->post())) {
         $results = $modelForm->giveAllProductsByName($modelForm->name);
         Yii::$app->session->setFlash('contactFormSubmitted');
         return $this->render('searchProducts', ['modelForm' => $modelForm, 'results' => $results]);
     } else {
         return $this->render('searchProducts', ['modelForm' => $modelForm, 'results' => $results]);
     }
 }
開發者ID:vodas,項目名稱:praktykirepofinito,代碼行數:12,代碼來源:SiteController.php

示例13: fakeProduct

 protected function fakeProduct()
 {
     $fakeProduct = new Product();
     $fakeProduct->serial_number = "P1284724";
     $fakeProduct->primary_name = "Fake Product";
     $fakeProduct->product_type_id = $this->fakeProductType()->product_type_id;
     $fakeProduct->currency_id = $this->fakeCurrency()->currency_id;
     $fakeProduct->client_id = $this->fakeClient()->client_id;
     $fakeProduct->supplier_id = $this->fakeSupplier()->supplier_id;
     $fakeProduct->save();
     return $fakeProduct;
 }
開發者ID:boylee1111,項目名稱:Reservation,代碼行數:12,代碼來源:DbTestCase.php

示例14: actionProduct

 public function actionProduct($id)
 {
     $modelProduct = new Product();
     foreach ($modelProduct->getProduct($id) as $product) {
         $idProduct = $product['id'];
         $nameProduct = $product['name'];
         $typeProduct = $product['type'];
         $priceProduct = $product['price'];
         $descriptionProduct = $product['description'];
         $imageProduct = $product['image'];
     }
     return $this->render('product', ['idProduct' => $idProduct, 'nameProduct' => $nameProduct, 'typeProduct' => $typeProduct, 'priceProduct' => $priceProduct, 'descriptionProduct' => $descriptionProduct, 'imageProduct' => $imageProduct]);
 }
開發者ID:royutoan,項目名稱:pianodanang,代碼行數:13,代碼來源:SiteController.php

示例15: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $product = new Product();
     $product->name = $request->input('name');
     $product->price = $request->input('price');
     $product->description = $request->input('description');
     $product->save();
     for ($i = 0; $i < $request->input('stock'); $i++) {
         $item = new ProductItem();
         $item->code = date('YmdHis') . '.' . $i;
         $item = $product->item()->save($item);
     }
 }
開發者ID:ambarsetyawan,項目名稱:laravel5-tokoonline,代碼行數:18,代碼來源:ProductController.php


注:本文中的app\models\Product類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。