本文整理汇总了PHP中app\Item::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::orderBy方法的具体用法?PHP Item::orderBy怎么用?PHP Item::orderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Item
的用法示例。
在下文中一共展示了Item::orderBy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
public function store(ItemRequest $request)
{
try {
$customers = Customer::all();
Item::create($request->all());
$item = Item::orderBy('created_at', 'desc')->first();
foreach ($customers as $customer) {
Price::create(['item_id' => $item->id, 'customer_id' => $customer->id, 'custom_price' => $item->price, 'sellable' => '1', 'is_custom' => '0']);
}
return redirect('item')->with('message', 'Data berhasil dibuat!');
} catch (\Illuminate\Database\QueryException $e) {
return redirect('item')->with('message', 'Data dengan nama tersebut sudah digunakan!');
} catch (\PDOException $e) {
return redirect('item')->with('message', 'Data dengan nama tersebut sudah digunakan!');
}
}
示例2: getExample1
public function getExample1()
{
//Order by amount
$items = \App\Item::orderBy('amount', 'asc')->get();
dump($items->toArray());
foreach ($items as $item) {
echo $item->name;
}
return 'Example 1';
}
示例3: add
public function add(Request $request)
{
//Get max item order id and add 1
$order = Item::orderBy('item_order', 'desc')->pluck('item_order');
$order++;
$item = new Item();
$item->title = $request->input('entry');
$item->item_order = $order;
$item->save();
$returnId = $item->id;
return array("id" => $returnId);
}
示例4: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$userid = Auth::id();
$items = Item::orderBy('item_name', 'asc')->get();
$editInput = Item::findOrFail($id);
$skuscan = null;
$email = User::where('id', $userid)->first()->email;
$scan = Scan::where('userEmail', $email)->first();
if ($scan) {
$skuscan = $scan;
}
$totalValue = Item::where('user', $userid)->sum('price');
$totalQuantity = Item::where('user', $userid)->sum('quantity');
return view('inventory', compact('items', 'editInput', 'totalValue', 'totalQuantity', 'skuscan'));
}
示例5: function
<?php
use App\Item;
$app->get('/', function () use($app) {
$items = Item::orderBy('item_order', 'asc')->get();
return view('index', ['items' => $items]);
});
$app->post('/add-item', 'App\\Http\\Controllers\\ItemController@add');
$app->post('/edit-item', 'App\\Http\\Controllers\\ItemController@edit');
$app->post('/delete-item', 'App\\Http\\Controllers\\ItemController@delete');
$app->post('/sort-items', 'App\\Http\\Controllers\\ItemController@sort');
示例6: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$items = App\Item::orderBy('name')->get();
return $items;
}
示例7: index
public function index()
{
$items = Item::orderBy('id', 'DESC')->paginate(10);
return view('item.index', compact('items'));
}