本文整理汇总了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);
}