當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。