本文整理汇总了PHP中app\models\Book::order方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::order方法的具体用法?PHP Book::order怎么用?PHP Book::order使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Book
的用法示例。
在下文中一共展示了Book::order方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
* Search for books
*
* @param string $terms
* @param array $advancedQueries @see self::$advancedQueryOptions for more information
* @param array $options @see self::$optionSettings for more information
*
* @return \App\Models\Book[]
*/
public function search($terms, array $advancedQueries = [], $options = [])
{
if (!$this->areAdvancedQueriesValid($advancedQueries)) {
return false;
}
$this->setDefaultOptions($options);
$query = $this->book->order($options['orderBy'], $options['order'])->page($options['page'], $options['limit']);
if ($terms) {
$query->searchFor($terms);
}
foreach ($advancedQueries as $key => $value) {
$method = $this->advanceQuerySettings[$key]['method'];
if ($key === 'range') {
list($from, $to) = $value;
$this->book->{$method}($from, $to);
} else {
$this->book->{$method}($value);
}
}
return $query->get();
}
示例2: queryAdvanced
private function queryAdvanced(array $queries = [])
{
$this->book->order($this->defaultOptions['orderBy'], $this->defaultOptions['order'])->page($this->defaultOptions['page'], $this->defaultOptions['limit']);
$queriesList = ['q' => 'searchFor', 'title' => 'searchTitle', 'author' => 'searchAuthor', 'isbn' => 'searchIsbn', 'date' => 'searchDate', 'range' => 'searchDateRange', 'rate' => 'searchRate'];
foreach ($queries as $key => $value) {
if ($key === 'range') {
list($from, $to) = $value;
$this->book->{$queriesList[$key]}($from, $to);
} else {
$this->book->{$queriesList[$key]}($value);
}
}
return $this->book->get()->toArray();
}