ptgen api point support parameter & default user

This commit is contained in:
xiaomlove
2022-02-28 23:20:42 +08:00
parent 5ed80ed637
commit b9d5df232b
51 changed files with 447 additions and 51 deletions

View File

@@ -80,17 +80,23 @@ class TorrentRepository extends BaseRepository
});
}
list($sortField, $sortType) = $this->getSortFieldAndType($params);
$query->orderBy($sortField, $sortType);
$query = $this->handleGetListSort($query, $params);
$with = ['user'];
$torrents = $query->with($with)
->orderBy('pos_state', 'desc')
->orderBy('id', 'desc')
->paginate();
$torrents = $query->with($with)->paginate();
return $torrents;
}
private function handleGetListSort(Builder $query, array $params)
{
if (empty($params['sort_field']) && empty($params['sort_type'])) {
//the default torrent list sort
return $query->orderBy('pos_state', 'desc')->orderBy('id', 'desc');
}
list($sortField, $sortType) = $this->getSortFieldAndType($params);
return $query->orderBy($sortField, $sortType);
}
public function getSearchBox($id = null)
{
if (is_null($id)) {