当前位置: 首页>>代码示例>>PHP>>正文


PHP Product::find方法代码示例

本文整理汇总了PHP中Product::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::find方法的具体用法?PHP Product::find怎么用?PHP Product::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Product的用法示例。


在下文中一共展示了Product::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $product = Product::find($id);
     $product->delete();
     Session::flash('message', 'successfully deleted the product!');
     return Redirect::to('products');
 }
开发者ID:amaurysoares,项目名称:codecommerce,代码行数:13,代码来源:AdminCategoriesController.php

示例2: post_delete

 public function post_delete()
 {
     $product = Product::find(Input::get('id'));
     $product->categories()->delete();
     $product->delete();
     return Redirect::back()->with('flash', true)->with('flash_type', 'success')->with('flash_msg', 'Product deleted successfully.');
 }
开发者ID:robmeijer,项目名称:seer,代码行数:7,代码来源:products.php

示例3: indexAction

 public function indexAction()
 {
     $this->view->products = Product::find();
     if ($this->session->get("auth")) {
         $this->view->user = User::findFirst($this->session->get("auth")['id']);
     }
 }
开发者ID:KarimTaha,项目名称:AdvancedLab,代码行数:7,代码来源:IndexController.php

示例4: show

 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function show($id)
 {
     // get the nerd
     $item = Product::find($id);
     // show the view and pass the nerd to it
     return View::make('product.show')->with('item', $item);
 }
开发者ID:pda-code,项目名称:eshop-angular-laravel,代码行数:13,代码来源:ProductController.php

示例5: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     $product = Product::find($id);
     $res = array();
     return Response::json($product);
 }
开发者ID:maldewar,项目名称:jidou,代码行数:13,代码来源:ProductController.php

示例6: getSearch

 public static function getSearch($input = array())
 {
     $result = Product::where(function ($query) use($input) {
         if (!empty($input['category_id'])) {
             $query = $query->where('category_id', $input['category_id']);
         }
         if (!empty($input['type_id'])) {
             $query = $query->where('type_id', $input['type_id']);
         }
         if (!empty($input['price_id'])) {
             $query = $query->where('price_id', $input['price_id']);
         }
         if (!empty($input['time_id'])) {
             $inputDate = getTime($input['time_id']);
             $query = $query->where('start_time', '>=', $inputDate);
         }
         if (!empty($input['city_id'])) {
             $query = $query->where('city_id', $input['city_id']);
         }
         if (!empty($input['city'])) {
             $query = $query->where('city', $input['city']);
         }
         if (!empty($input['name'])) {
             $query = $query->where('name', 'like', '%' . $input['name'] . '%');
         }
         //lat long
         $query = $query->where('status', ACTIVE);
     })->select(listFieldProduct())->get();
     foreach ($result as $key => $value) {
         $value->avatar = url(PRODUCT_UPLOAD . '/' . $value->user_id . '/' . Product::find($value->id)->avatar);
         $value->block = Common::checkBlackList(Input::get('user_id'), $value->user_id);
     }
     return $result;
 }
开发者ID:trantung,项目名称:online_market,代码行数:34,代码来源:CommonSearch.php

示例7: addCart

 public function addCart($id)
 {
     $product = Product::find($id);
     $quantity = Input::get('qt');
     $name = $product->name;
     if (intval($quantity) > $product->stock) {
         return Redirect::to('product/' . $id)->with('message', 'La quantité du stock est insufisante pour votre commande');
     }
     if (Session::has('cart')) {
         $carts = Session::get('cart', []);
         foreach ($carts as &$item) {
             if ($item['name'] == $name) {
                 $item["quantity"] += intval($quantity);
                 Session::set('cart', $carts);
                 return Redirect::to('product/' . $id)->with('message', 'Votre panier a été mis à jour');
             }
         }
     }
     $new_item = array();
     $new_item['name'] = $name;
     $new_item['price'] = $product->price;
     $new_item['quantity'] = intval($quantity);
     $new_item['description'] = $product->description;
     $new_item['picture'] = $product->picture;
     Session::push('cart', $new_item);
     return Redirect::to('product/' . $id)->with('message', 'Le produit a été ajouté à votre panier');
 }
开发者ID:spark942,项目名称:supinternet-projects,代码行数:27,代码来源:CartController.php

示例8: postAddtocart

 public function postAddtocart()
 {
     $product = Product::find(Input::get('id'));
     $quantity = Input::get('quantity');
     Cart::insert(array('id' => $product->id, 'name' => $product->title, 'price' => $product->price, 'quantity' => $quantity, 'image' => $product->image));
     return Redirect::to('store/cart');
 }
开发者ID:y471n,项目名称:laravel-ecomm,代码行数:7,代码来源:StoreController.php

示例9: showCart

 public function showCart()
 {
     $session_items = $cart_items = [];
     if (Session::has('cart') && !empty(Session::get('cart'))) {
         $session_items = Session::get('cart');
         foreach ($session_items as $item) {
             $unserialized_item = unserialize($item);
             $product = Product::find($unserialized_item->productId);
             $cart_item = new StdClass();
             $cart_item->p_id = $product->id;
             $cart_item->name = $product->name;
             $cart_item->image = $product->image;
             $cart_item->price = $product->price;
             $cart_item->qtt = $unserialized_item->qtt;
             $cart_item->total = $cart_item->price * $cart_item->qtt;
             $counter = 0;
             $found = false;
             $index = null;
             foreach ($cart_items as $it) {
                 if ($it->p_id == $product->id) {
                     $index = $counter;
                     $found = true;
                 }
                 $counter++;
             }
             if ($found) {
                 $cart_items[$index]->qtt = $cart_items[$index]->qtt + $cart_item->qtt;
                 $cart_items[$index]->total = $cart_items[$index]->qtt * $cart_item->price;
             } else {
                 $cart_items[] = $cart_item;
             }
         }
     }
     return View::make('cart', compact('cart_items'));
 }
开发者ID:Pixelsltd,项目名称:e-commerce-1,代码行数:35,代码来源:HomeController.php

示例10: find

 /**
  * Find a model by its primary key.
  *
  * @param  mixed  $id
  * @param  array  $columns
  * @return \Illuminate\Support\Collection|static
  */
 public function find($id)
 {
     $model = Product::find($id);
     if ($model) {
         return $model;
     }
     throw new ResourceNotFoundException('Product was not found.');
 }
开发者ID:dasigr,项目名称:laravelcommerce,代码行数:15,代码来源:ProductRepository.php

示例11: postAddtocart

 public function postAddtocart()
 {
     $product = Product::find(Input::get('id'));
     $quantity = Input::get('quantity');
     $member_id = Auth::user()->id;
     Cart::create(array('product_id' => $product->id, 'name' => $product->title, 'price' => $product->price, 'quantity' => $quantity, 'image' => $product->image, 'member_id' => $member_id));
     return Redirect::to('store/cart');
 }
开发者ID:ayooby,项目名称:laravel4-ecomm,代码行数:8,代码来源:StoreController.php

示例12: show

 public function show()
 {
     if (!isset($_GET['id'])) {
         return call('pages', 'error');
     }
     $product = Product::find($_GET['id']);
     require_once 'views/products/show.php';
 }
开发者ID:Hield,项目名称:e-commerce,代码行数:8,代码来源:products_controller.php

示例13: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 50) as $index) {
         $number = rand(1, 5);
         $product = Product::find($number);
         Record::create(["name" => $product->name, "action" => "trials", "status" => "comes_in", "authorization" => $faker->firstNameFemale, "amount" => 5 + $index * 5, "product_id" => $number]);
     }
 }
开发者ID:hunt-son,项目名称:inventory-app-2,代码行数:9,代码来源:RecordsTableSeeder.php

示例14: indexAction

 public function indexAction()
 {
     // set title page
     Tag::setTitle("Home");
     $behandeling = Behandeling::find();
     $product = Product::find();
     $this->view->setVar('behandeling', $behandeling);
     $this->view->setVar('product', $product);
 }
开发者ID:Ugur22,项目名称:capelli_haarmode,代码行数:9,代码来源:IndexController.php

示例15: it_should_upload_single_media

 /** @test */
 public function it_should_upload_single_media()
 {
     config()->set('medias.models', ['products' => ['model' => 'Product', 'fields' => ['cover']]]);
     $product = new Product();
     $product->id = 1;
     $product->uploadSingleMedia($this->getPicture(), 'cover');
     $product->save();
     $this->assertNotNull(Product::find(1)->cover);
 }
开发者ID:escapework,项目名称:laramedias,代码行数:10,代码来源:MediasTest.php


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