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


PHP Product::where方法代码示例

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


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

示例1: category

 /**
  * Show all products by category id.
  *
  * @param $id
  * @return \Illuminate\View\View
  */
 public function category($id)
 {
     $categories = $this->category->orderBy('name')->get();
     $products = $this->product->where('category_id', '=', $id)->paginate(8);
     $categoryName = $this->category->find($id)->name;
     return view('ecomm.shop.partial.products-category', compact('categories', 'products', 'categoryName'));
 }
开发者ID:JimiOhrid,项目名称:shopStore,代码行数:13,代码来源:StoreController.php

示例2: home

 public function home()
 {
     //$data['forsidumyndir'] = \App\Page::where('slug', '_forsidumyndir')->first()->getSubs();
     $cats = \App\Category::where('status', 1)->get();
     $prods = \App\Product::where('status', 1)->get();
     $items = [$cats, $prods];
     $kubbar = [];
     foreach ($items as $item) {
         foreach ($item as $v) {
             $frontpaged = trim($v->extras()->get('frontpaged')) ?: 0;
             $size = trim($v->extras()->get('size'));
             $titill = trim($v->extras()->get('titill')) ?: $v->title;
             if ($frontpaged && $frontpaged != 0) {
                 $kubbar[] = ['title' => $titill, 'size' => $size ? $size : 1, 'frontpaged' => $frontpaged, 'fillimage' => $v->fillimage ? true : false, 'path' => $v->fullPath(), 'image' => $v->img()->first(), 'slug' => $v->slug];
             }
         }
     }
     usort($kubbar, function ($a, $b) {
         if ($a['frontpaged'] == $b['frontpaged']) {
             return 0;
         }
         return $a['frontpaged'] < $b['frontpaged'] ? -1 : 1;
     });
     $data['kubbar'] = $kubbar;
     return view('frontend.layout')->with($data);
 }
开发者ID:stjanilofts,项目名称:lh,代码行数:26,代码来源:HomeController.php

示例3: show

 public function show($slug)
 {
     // Tökum bara síðasta stykkið
     $e = array_filter(explode("/", $slug));
     $last = end($e);
     $item = \App\Category::where('status', 1)->where('slug', $last)->first();
     if ($item) {
         $cats = \App\Category::where('status', 1)->where('parent_id', $item->id)->orderBy('order')->get();
         $prods = \App\Product::where('status', 1)->where('category_id', $item->id)->orderBy('order')->get();
         $data['items'] = $cats->merge($prods);
         $data['title'] = $item->title;
         return view('frontend.products')->with($data);
     }
     $item = \App\Product::where('status', 1)->where('slug', $last)->first();
     if (!$item) {
         if (!$item) {
             abort(404, 'Fann ekki síðu!');
         }
     }
     $data['item'] = $item;
     $data['siblings'] = $item->getSiblings();
     $data['title'] = isset($item->category->title) ? $item->category->title : 'Vörur';
     if ($item->category_id < 1) {
         $data['title'] = $item->title;
     }
     return view('frontend.product')->with($data);
 }
开发者ID:stjanilofts,项目名称:ofncms,代码行数:27,代码来源:VorukerfiController.php

示例4: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $order = Order::findOrFail($id);
     $categories = Category::all();
     $products = Product::where('category_id', '=', $categories[0]->id)->get();
     return view('order.show', compact('order', 'categories', 'products'));
 }
开发者ID:alexdachin,项目名称:phppos,代码行数:13,代码来源:OrderController.php

示例5: show

 public function show($slug)
 {
     $product = Product::where('slug', $slug)->first();
     //dd($products);
     return view('store.show', compact('product'));
     //Envia los datos a la vista
 }
开发者ID:edgarxene,项目名称:Store-X,代码行数:7,代码来源:StoreController.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $keyword = Input::get('keyword');
     $products = Product::where('nome', '=', '%' . $keyword . '%')->get();
     //        var_dump('search results');
     return redirect()->route('search');
 }
开发者ID:EJCM,项目名称:rodalol,代码行数:13,代码来源:SearchController.php

示例7: eshopRefer

 public function eshopRefer(Request $request)
 {
     if ($request->isMethod('post')) {
         $id = $request->input('id');
         $query = App\Product::where('id', $id)->increment('clicks');
     }
 }
开发者ID:bausano,项目名称:Ebchod,代码行数:7,代码来源:AjaxController.php

示例8: search

 public static function search($type, $size, $maxPrice, $minPrice, $colors)
 {
     if ($colors == null) {
         $colors = Color::all();
         foreach ($colors as $key => $color) {
             $colors[$key] = $color->id;
         }
     }
     if ($colors != null && $type == null && $size == null) {
         return Product::where('price', '>=', $minPrice)->where('price', '<=', $maxPrice)->whereHas('colors', function ($query) use($colors) {
             $query->whereIn('id', $colors);
         })->get();
     }
     if ($type == null) {
         return Product::where('size', $size)->where('price', '>=', $minPrice)->where('price', '<=', $maxPrice)->whereHas('colors', function ($query) use($colors) {
             $query->whereIn('id', $colors);
         })->get();
     }
     if ($size == null) {
         return Product::where('FK_type', $type)->where('price', '>=', $minPrice)->where('price', '<=', $maxPrice)->whereHas('colors', function ($query) use($colors) {
             $query->whereIn('id', $colors);
         })->get();
     }
     return Product::where('size', $size)->where('FK_type', $type)->where('price', '>=', $minPrice)->where('price', '<=', $maxPrice)->whereHas('colors', function ($query) use($colors) {
         $query->whereIn('id', $colors);
     })->get();
 }
开发者ID:rubenwouters,项目名称:Hello-Maternity,代码行数:27,代码来源:Product.php

示例9: product

 public function product($productkey)
 {
     $product = Product::where('key', $productkey)->first();
     if ($product != null) {
         // metadata
         $site_title = $product->name . ' - ' . Config::findByKey('site_title')->first()->value;
         SEOMeta::setTitle($site_title);
         SEOMeta::setDescription($product->meta_description);
         SEOMeta::addKeyword([$product->meta_keywords]);
         SEOMeta::addMeta('article:published_time', $product->created_at->toW3CString(), 'property');
         if (isset($product->categories->first()->name)) {
             SEOMeta::addMeta('article:section', $product->categories->first()->name, 'property');
         }
         OpenGraph::setTitle($site_title);
         OpenGraph::setDescription($product->meta_description);
         OpenGraph::setUrl(route('product', ['productkey' => $productkey]));
         OpenGraph::addProperty('type', 'article');
         OpenGraph::addProperty('locale', app()->getLocale());
         OpenGraph::addProperty('locale:alternate', ['vi-vn', 'en-us']);
         OpenGraph::addImage($product->getFirstAttachment());
         OpenGraph::addImage($product->attachments->lists('path'));
         OpenGraph::addImage(['url' => Image::url($product->getFirstAttachment(), 300, 300, array('crop')), 'size' => 300]);
         // end metadata
         return view('frontend.pages.product', compact('product'));
     } else {
         abort(404);
     }
 }
开发者ID:phantsang,项目名称:1u0U39rjwJO4Vmnt99uk9j6,代码行数:28,代码来源:PagesController.php

示例10: loadFeed

 /**
  *
  */
 public function loadFeed()
 {
     $xml = $this->reader->load($this->feedUrl);
     $content = $xml->getContent();
     $this->content = $xml->getContent();
     foreach ($content as $product) {
         $item = Product::where('externalUrl', '=', $product->productUrl)->first();
         if (!$item) {
             $item = new Product();
         }
         if (strlen($product->brand) > 1) {
             $brand = Brand::where('name', '=', $product->brand)->first();
             if (!$brand) {
                 $brand = new Brand();
                 $brand->name = $product->brand;
                 $brand->save();
             }
             if ($brand->id) {
                 $item->brand = $brand->id;
             }
         }
         $item->name = $product->name;
         $item->description = $product->description;
         $item->price = $product->price;
         $item->regularPrice = $product->regularPrice;
         $item->shippingPrice = $product->shippingPrice;
         $item->externalUrl = $product->productUrl;
         $item->imageUrl = $product->graphicUrl;
         $item->save();
     }
 }
开发者ID:jimmitjoo,项目名称:feedparser,代码行数:34,代码来源:FeedParser.php

示例11: create

 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $my_groups = Customer::where('id', $this->my_customer_id)->first()->groups()->where('active', '1')->get();
     $products = Product::where('active', '1')->get();
     $severities = Severity::orderBy('priority_order')->orderBy('name')->get();
     return view('layouts.ticket.new', ['my_groups' => $my_groups, 'products' => $products, 'severities' => $severities]);
 }
开发者ID:stryker250,项目名称:simple_ticket,代码行数:12,代码来源:TicketController.php

示例12: generate

    public function generate($platform, $productID)
    {
        if ($product = Product::where('id', '=', $productID)->first()) {
            $title = $product->name;
            $description = $product->description;
        } else {
            $title = "Title not available";
            $description = "Description not available";
        }
        if ($platform == "facebook") {
            echo '
            
            <title>' . $title . '</title>
            <meta name="description" content="' . $description . '">
<img src="http://media.giphy.com/media/109Ku3hdapZJle/giphy.gif" /> 
            ';
        } else {
            echo '
                
                
            <title>Hmm intresting didnt know about "' . $platform . '" will sure check it out</title>
                
                ';
        }
    }
开发者ID:EDDYMENS,项目名称:Zowy,代码行数:25,代码来源:postGenerator.php

示例13: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($id)
 {
     $product = Product::where('id', $id)->get()[0];
     $sliders = Slider::all();
     $categories = Category::all();
     return view('product', compact('sliders', 'categories', 'product'));
 }
开发者ID:MostafaEllethy,项目名称:alexsport,代码行数:12,代码来源:ProductController.php

示例14: index

 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $products = Product::where('quantity', '>', 0)->orderBy('created_at', 'DESC')->limit(10)->get();
     $id = Auth::id();
     $shoppingCart = ShoppingCart::find(md5($id));
     return view('pages.home', compact('products', 'shoppingCart'));
 }
开发者ID:hao1987,项目名称:winterfell,代码行数:12,代码来源:ProductController.php

示例15: getProductsStatus

 public function getProductsStatus($id)
 {
     $res = new \StdClass();
     $res->list = new \StdClass();
     $res->list->done_products = round(DB::table('products')->select(DB::raw('sum(unitprice*quantity) as product_sum'))->whereNull('deleted_at')->where('list', '=', $id)->where('status', 'done')->first()->product_sum);
     $res->list->all_products = round(DB::table('products')->select(DB::raw('sum(unitprice*quantity) as product_sum'))->whereNull('deleted_at')->where('list', '=', $id)->first()->product_sum);
     $res->list->budget = round(ShoppingList::find($id)->budget);
     $products = Product::where('list', '=', $id)->get();
     $res->statuses = [];
     $res->product_info = [];
     foreach ($products as $product) {
         $res->statuses[$product->status][] = $product->id;
         $p = new \StdClass();
         $p->id = $product->id;
         $p->name = $product->name;
         $p->unitprice = $product->unitprice;
         $p->quantity = $product->quantity;
         $p->moms = $product->moms;
         $res->product_info[] = $p;
     }
     $res->deleted_products = [];
     foreach (DB::table('products')->where('list', '=', $id)->whereNotNull('deleted_at')->get() as $p) {
         $res->deleted_products[] = $p->id;
     }
     return response()->json($res);
 }
开发者ID:jonasdahl,项目名称:mammeriet,代码行数:26,代码来源:ListApiController.php


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