mirror of
https://github.com/Kovah/LinkAce.git
synced 2025-01-17 21:28:30 +01:00
Fix random sorting for guests
This commit is contained in:
parent
328ef58cad
commit
2cf94d1db9
@ -18,15 +18,18 @@ class LinkController extends Controller
|
|||||||
public function index(Request $request): View
|
public function index(Request $request): View
|
||||||
{
|
{
|
||||||
$links = Link::publicOnly()
|
$links = Link::publicOnly()
|
||||||
->with('tags')
|
->with('tags');
|
||||||
->orderBy(
|
|
||||||
$request->input('orderBy', 'created_at'),
|
$orderBy = $request->input('orderBy', 'created_at');
|
||||||
$request->input('orderDir', 'desc')
|
$orderDir = $request->input('orderDir', 'desc');
|
||||||
)
|
if ($orderBy == 'random') {
|
||||||
->paginate(getPaginationLimit());
|
$links->inRandomOrder();
|
||||||
|
} else {
|
||||||
|
$links->orderBy($orderBy, $orderDir);
|
||||||
|
}
|
||||||
|
|
||||||
return view('guest.links.index', [
|
return view('guest.links.index', [
|
||||||
'links' => $links,
|
'links' => $links->paginate(getPaginationLimit()),
|
||||||
'route' => $request->getBaseUrl(),
|
'route' => $request->getBaseUrl(),
|
||||||
'orderBy' => $request->input('orderBy', 'created_at'),
|
'orderBy' => $request->input('orderBy', 'created_at'),
|
||||||
'orderDir' => $request->input('orderDir', 'desc'),
|
'orderDir' => $request->input('orderDir', 'desc'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user