本文整理匯總了PHP中Eloquent::orderBy方法的典型用法代碼示例。如果您正苦於以下問題:PHP Eloquent::orderBy方法的具體用法?PHP Eloquent::orderBy怎麽用?PHP Eloquent::orderBy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Eloquent
的用法示例。
在下文中一共展示了Eloquent::orderBy方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: doOrdering
/**
* Datatable ordering
*
* @return null
*/
private function doOrdering()
{
if (array_key_exists('order', $this->input) && count($this->input['order']) > 0) {
for ($i = 0, $c = count($this->input['order']); $i < $c; $i++) {
$order_col = (int) $this->input['order'][$i]['column'];
$order_dir = $this->input['order'][$i]['dir'];
if ($this->new_version) {
$column = $this->input['columns'][$order_col];
if ($column['orderable'] == "true") {
if (!empty($column['name'])) {
$this->query->orderBy($column['name'], $order_dir);
} elseif (isset($this->columns[$order_col])) {
$column_name = $this->getColumnName($this->columns[$order_col]);
$this->query->orderBy($column_name, $order_dir);
}
}
} else {
if (isset($this->columns[$order_col])) {
if ($this->input['columns'][$order_col]['orderable'] == "true") {
$column_name = $this->getColumnName($this->columns[$order_col]);
$this->query->orderBy($column_name, $order_dir);
}
}
}
}
}
}
示例2: retrieveRecords
protected function retrieveRecords()
{
return $this->Model->orderBy($this->getOrderByColumn(), $this->getOrderByDirection())->paginate($this->recordsPerPage);
}