本文整理汇总了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'));
}
示例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);
}
示例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);
}
示例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'));
}
示例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
}
示例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');
}
示例7: eshopRefer
public function eshopRefer(Request $request)
{
if ($request->isMethod('post')) {
$id = $request->input('id');
$query = App\Product::where('id', $id)->increment('clicks');
}
}
示例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();
}
示例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);
}
}
示例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();
}
}
示例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]);
}
示例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>
';
}
}
示例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'));
}
示例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'));
}
示例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);
}