• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP models\Product类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中app\models\Product的典型用法代码示例。如果您正苦于以下问题:PHP Product类的具体用法?PHP Product怎么用?PHP Product使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Product类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: show

 /**
  * Display Generator Page
  *
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function show(Request $request)
 {
     /** @var $product Product */
     if (!($product = $this->product->whereCode($request->get('product_id'))->orWhere('id', $request->get('product_id'))->first())) {
         return response()->json(['error' => 'invalid_code']);
     }
     /**
      * Encode Image if necessary
      */
     if (filter_var($request->get('encode_image', false), FILTER_VALIDATE_BOOLEAN) === true) {
         $product->setAttribute('image', dispatch(new EncodeImageJob(substr($product->getAttribute('image'), 1))));
     }
     return response()->json($product->load('extras', 'profile'));
 }
开发者ID:SkysoulDesign,项目名称:mirage.dev,代码行数:20,代码来源:ProductController.php


示例17: saveTags

 public function saveTags(Product $product, array $tags)
 {
     $results = [];
     foreach ($tags as $tag) {
         $tag = trim($tag);
         $find = Tag::where('name', $tag)->first();
         if (!$find) {
             $find = Tag::create(['name' => $tag]);
         }
         $results[] = $find;
     }
     $product_ids = collect($results)->pluck('id');
     $product->tags()->attach($product_ids->toArray());
     return $results;
 }
开发者ID:amteknologi,项目名称:e-commerce,代码行数:15,代码来源:ProductRepository.php


示例18: run

 public function run()
 {
     DB::table('products')->truncate();
     $faker = Faker\Factory::create();
     $lorem = new Faker\Provider\Lorem($faker);
     $random = new Faker\Provider\Base($faker);
     for ($i = 0; $i < 500; $i++) {
         $name = $lorem->word();
         $product = new Product();
         $product->slug = Str::slug($name);
         $product->name = ucfirst($name);
         $product->price = $random->randomNumber(2);
         $product->save();
     }
 }
开发者ID:Denniskevin,项目名称:demo-cart,代码行数:15,代码来源:ProductTableSeeder.php


示例19: store

 public function store(Request $request)
 {
     $input = $request->json()->all();
     unset($input['categories']);
     $product = new Product($input);
     $product->save();
     if (($categories = $request->json()->get('categories')) && !empty($categories)) {
         if (is_string($categories)) {
             $categories = explode(',', $categories);
         }
         $product->categories()->attach($categories);
     }
     $product->load('categories');
     return response()->created($product);
 }
开发者ID:kshar1989,项目名称:dianpou,代码行数:15,代码来源:ProductController.php


示例20: setUp

 public function setUp()
 {
     parent::setUp();
     $this->resetEvents('App\\Models\\Product', 'App\\Models\\ProductStock', 'App\\Models\\ProductPhoto', 'App\\Models\\UploadFile');
     $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;
     });
     $this->shared('stock', function () {
         return $this->product->stocks()->save(new ProductStock(["option" => ["深空灰", "16GB"], "sku" => uniqid(), "stocks" => 100, "price" => 5288]));
         $stock->save();
         return $stock;
     });
 }
开发者ID:kshar1989,项目名称:dianpou,代码行数:15,代码来源:ProductStockPhotoTest.php



注:本文中的app\models\Product类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP models\Profile类代码示例发布时间:2022-05-23
下一篇:
PHP models\Post类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap