本文整理汇总了PHP中app\models\Product::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::orderBy方法的具体用法?PHP Product::orderBy怎么用?PHP Product::orderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Product
的用法示例。
在下文中一共展示了Product::orderBy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: products
/**
* @return \Illuminate\Http\JsonResponse
*/
public function products()
{
$distributors = Distributor::all();
$products = Product::orderBy('name')->get();
$product_count = 0;
foreach ($products as $product) {
$dist_name = Distributor::where('id', '=', $product->distributor_id);
if ($dist_name->count()) {
$dist_name = $dist_name->first()->name;
$products[$product_count]->distributor_name = $dist_name;
}
$product_count++;
}
return response()->json(['distributors' => $distributors, 'products' => $products]);
}
示例2: paginateProduct
public function paginateProduct($page)
{
return Product::orderBy('id', 'desc')->paginate($page);
}
示例3: index
/**
* Untuk menampilkan semua data product
*
* @return [type] [description]
*/
public function index()
{
return ['status' => 'success', 'products' => Product::orderBy('id', 'desc')->get()];
}
示例4: index
/**
* Show the home page to the user.
*
* @return Response
*/
public function index()
{
$data['brands'] = Brands::all();
$data['latest'] = Product::orderBy('product_id', 'desc')->take('6')->get();
return view('frontend/livesearch', $data);
}
示例5: newProducts
public function newProducts()
{
$products = Product::orderBy('created_at', 'desc')->limit(10);
return view('site.pages.popular')->with('products', $products);
}