本文整理汇总了PHP中app\models\Order::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::orderBy方法的具体用法?PHP Order::orderBy怎么用?PHP Order::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Order
的用法示例。
在下文中一共展示了Order::orderBy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
function generate()
{
/* INV-ddmmyyyXXXXX (INV-0206201500356) */
// $lastInvoice = "INV-270720150001";
$orders = new Order();
$lastOrder = $orders->orderBy('created_at', 'desc')->first();
if ($lastOrder) {
$lastInvoice = $lastOrder->invoice_no;
}
# date configuration
$date = Date('d');
$month = Date('m');
$year = Date('Y');
$newInvoice = "";
if (!$lastOrder || !$lastInvoice) {
$newInvoice = "INV-" . $date . $month . $year . "0001";
} else {
#get the month of the lastInvoice
$last_inv_month = substr($lastInvoice, 6, 2);
if (!$last_inv_month == $month) {
$increment = "0001";
} else {
#get last four digit of last invoice number
$zeroDigits = "";
$invoice_length = strlen($lastInvoice);
$last_increment = intval(substr($lastInvoice, $lastInvoice - 4, 4));
for ($c = 0; $c < 4 - $last_increment; $c++) {
$zeroDigits = $zeroDigits . "0";
}
$new_increment = strval($last_increment + 1);
$newInvoice = "INV-" . $date . $month . $year . $zeroDigits . $new_increment;
}
}
return $newInvoice;
}
示例2: get_group_orders
public function get_group_orders()
{
$orders = Order::orderBy('id', 'desc')->groupBy('order_id')->get();
return $orders;
}
示例3: index
/**
* Shows table with orders, ordered by status code (pending first) and time created
*
* @return Response
*/
public function index()
{
$orders = Order::orderBy('status_code_id')->orderBy('created_at', 'asc')->paginate(self::PAGINATION_SIZE);
return view('admin.orders.index', compact('orders'));
}
示例4: messages
public function messages()
{
$messages = Order::orderBy('created_at', 'desc')->get();
return view('admin.messages')->with('messages', $messages);
}