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


PHP Product::orderBy方法代码示例

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


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

示例1: loadTable

 public function loadTable()
 {
     $products = Product::orderBy('name', 'asc')->with('category')->get();
     $products->updated_at = '100';
     $products_f = ['data' => $products];
     echo json_encode($products_f);
 }
开发者ID:nguyentantintb,项目名称:wedding-card,代码行数:7,代码来源:ProductController.php

示例2: getAdd

 public function getAdd(Request $request)
 {
     $lastProduct = Product::orderBy('created_at', 'DESC')->first();
     $perpage = 12;
     $imgs = Img::where('img_block', '=', 'public')->orderBy('created_at', 'DESC')->simplePaginate($perpage);
     return view('manage.product.add', ['TITLE' => '新增商品', 'META_KEYWORDS' => META_KEYWORDS, 'META_DESC' => META_DESC, 'PAGE_CODE' => '/manage/product/add', 'lastProduct' => $lastProduct, 'imgs' => $imgs]);
 }
开发者ID:verchielxy,项目名称:jiedenuo,代码行数:7,代码来源:ProductController.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $products = Product::orderBy('name', 'asc')->paginate();
     $products->setPath(route('products.index'));
     //dd($products);
     return view("products.lista", compact('products'));
 }
开发者ID:serranozafra,项目名称:pruebaHectorSerrano,代码行数:12,代码来源:ProductController.php

示例4: store

 /**
  * Save a new snapshot.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $snapshotUrl = $request->file('snapshot_url');
     if ($snapshotUrl) {
         $filename = time() . '.' . $snapshotUrl->getClientOriginalExtension();
         $filepath = '/snapshots/' . $filename;
         if (!Storage::disk('s3')->put($filepath, file_get_contents($snapshotUrl), 'public')) {
             $filename = '';
         }
     }
     $this->validate($request, ['store_id' => 'required']);
     if (!$request->id) {
         $snapshot = Snapshot::create(['store_id' => $request->store_id, 'notes' => $request->notes, 'snapshot_url' => isset($filepath) ? $filepath : '']);
     } else {
         $snapshot = Snapshot::find($request->id);
         $snapshot->store_id = $request->store_id;
         $snapshot->notes = $request->notes;
         if ($snapshotUrl) {
             $snapshot->snapshot_url = $filepath;
         }
         $snapshot->save();
     }
     $for_sale = Product::orderBy('name')->where('store_id', $request->store_id)->where('product_status', 1)->get();
     foreach ($for_sale as $item) {
         $snapshot->products()->attach($item->id);
     }
     return redirect('/snapshot');
 }
开发者ID:aducworth,项目名称:inventory,代码行数:34,代码来源:SnapshotController.php

示例5: getIndex

 public function getIndex()
 {
     $posts = Post::orderBy('created_at', 'desc')->take(5)->get();
     $products = Product::orderBy('created_at', 'desc')->take(5)->get();
     $references = Reference::orderBy('created_at', 'desc')->take(5)->get();
     return view('admin/index', ['posts' => $posts, 'products' => $products, 'references' => $references]);
 }
开发者ID:smax22,项目名称:personal-homepage,代码行数:7,代码来源:AdminController.php

示例6: showProduct

 /**
  * Display the details and order form of a product
  *
  * @param $id
  * @param string $slug
  */
 public function showProduct($id, $slug = '')
 {
     $bests = Product::orderBy('score', 'desc')->orderBy('price', 'desc')->take(4)->get();
     $product = Product::findOrFail($id);
     $title = "Product {$product->name}";
     return view('front.prod', compact('product', 'bests', 'title', 'customer_id'));
 }
开发者ID:yinilauriot,项目名称:StarWars,代码行数:13,代码来源:FrontController.php

示例7: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $products = Product::orderBy('priority')->get();
     if ($request->ajax()) {
         return $products->toArray();
     }
     return view('admin.products.index', ['products' => $products]);
 }
开发者ID:phantsang,项目名称:1u0U39rjwJO4Vmnt99uk9j6,代码行数:13,代码来源:ProductsController.php

示例8: productManagement

 public function productManagement()
 {
     $page = 'partials.admin-productManagement';
     $users = User::all();
     $products = Product::orderBy('created_at', 'desc')->paginate(8);
     $products->setPath('');
     return view('quantri/admin', compact('page', 'users', 'products'));
 }
开发者ID:huyle2607,项目名称:eCommerce-Laravel-5.1,代码行数:8,代码来源:PagesController.php

示例9: index

 public function index($id = null)
 {
     if ($id == null) {
         return Product::orderBy('id', 'asc')->get();
     } else {
         return $this->show($id);
     }
 }
开发者ID:ankitdacoder,项目名称:sports,代码行数:8,代码来源:products.php

示例10: home

 public function home()
 {
     if ($this->isCrawler()) {
         $products = Product::orderBy('created_at', 'desc')->limit(20)->get();
         return view('crawler.home', ['products' => $products]);
     } else {
         return view('beta');
     }
 }
开发者ID:Kaelcao,项目名称:colormev2,代码行数:9,代码来源:PublicCrawlController.php

示例11: index

 public function index()
 {
     $count_hodon = Hoadon::count();
     $count_sanpham = Product::count();
     $count_danhgia = Danhgia::count();
     $product = Product::orderBy('id', 'DESC')->take(3)->get()->toArray();
     $donhang = Hoadon::orderBy('id', 'DESC')->take(4)->get();
     return view('backend.home', compact('count_hodon', 'count_sanpham', 'count_danhgia', 'product', 'donhang'));
 }
开发者ID:nguyentandat43,项目名称:booksonline,代码行数:9,代码来源:TrangchuContronller.php

示例12: products

 public function products(Request $request)
 {
     if ($request->sort && $request->orderby) {
         $products = Product::orderBy($request->sort, $request->orderby)->paginate(15);
     } else {
         $products = Product::orderBy('created_at', 'desc')->paginate(15);
     }
     return view('admin.products', compact('products'));
 }
开发者ID:omasterdesign,项目名称:omasterdefault,代码行数:9,代码来源:AdminController.php

示例13: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $page = $request->input('page', null);
     $perpage = 10;
     $skip = ($page - 1) * $perpage;
     $orderBy = $request->input('sort', null) == 'DESC' ? 'DESC' : 'ASC';
     $products = Product::orderBy('name', $orderBy)->skip($skip)->take($perpage)->get()->toArray();
     return Response::json(array('error' => false, 'products' => $products), 200);
 }
开发者ID:dk-napster,项目名称:rest_api_simple_laravel,代码行数:14,代码来源:ProductController.php

示例14: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $sliders = Slider::all();
     $categories = Category::all();
     $products = Product::orderBy('id', 'desc')->take(12)->get();
     $discount_products = Product::where('discount', '=', 'true')->take(12)->get();
     $random_products = Product::orderByRaw("RAND()")->take(10)->get();
     return view('home', compact('sliders', 'categories', 'products', 'discount_products', 'random_products'));
 }
开发者ID:MostafaEllethy,项目名称:alexsport,代码行数:14,代码来源:HomeController.php

示例15: postSearch

 public function postSearch()
 {
     $products = Product::orderBy('id', 'DESC')->paginate(25);
     $categories = new Category();
     $categoryAll = $categories->getCategoriesDropDown();
     $category_id = Input::get('category_id');
     $product_id = Input::get('product_id');
     $productsName = Product::where('category_id', '=', $category_id)->where('id', '=', $product_id)->get();
     return view('Products.list', compact('products'))->with('categoryAll', $categoryAll)->with('productsName', $productsName);
 }
开发者ID:rockyamdad,项目名称:cemcoErp,代码行数:10,代码来源:ProductController.php


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