本文整理匯總了PHP中app\models\Item::orderBy方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::orderBy方法的具體用法?PHP Item::orderBy怎麽用?PHP Item::orderBy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Item
的用法示例。
在下文中一共展示了Item::orderBy方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
//List all items
$items = Item::orderBy('name', 'ASC')->get();
// Barcode
$barcode = Barcode::first();
//Load the view and pass the items
return view('inventory.item.index')->with('items', $items)->with('barcode', $barcode);
}
示例2: deleteSomeItems
/**
* Delete some items
* This broke my tests, because I then had children existing
* whose parents were deleted, so when I tried to update the child,
* it errored saying that parent didn't exist.
*/
private function deleteSomeItems()
{
$items = Item::orderBy('id', 'desc')->limit(4)->get();
foreach ($items as $item) {
$item->delete();
}
}