本文整理汇总了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);
}
示例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]);
}
示例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'));
}
示例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');
}
示例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]);
}
示例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'));
}
示例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]);
}
示例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'));
}
示例9: index
public function index($id = null)
{
if ($id == null) {
return Product::orderBy('id', 'asc')->get();
} else {
return $this->show($id);
}
}
示例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');
}
}
示例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'));
}
示例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'));
}
示例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);
}
示例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'));
}
示例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);
}