1
0
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:
chrissawyerfan4 2023-04-14 01:59:00 +02:00
parent 328ef58cad
commit 2cf94d1db9

View File

@ -18,15 +18,18 @@ class LinkController extends Controller
public function index(Request $request): View
{
$links = Link::publicOnly()
->with('tags')
->orderBy(
$request->input('orderBy', 'created_at'),
$request->input('orderDir', 'desc')
)
->paginate(getPaginationLimit());
->with('tags');
$orderBy = $request->input('orderBy', 'created_at');
$orderDir = $request->input('orderDir', 'desc');
if ($orderBy == 'random') {
$links->inRandomOrder();
} else {
$links->orderBy($orderBy, $orderDir);
}
return view('guest.links.index', [
'links' => $links,
'links' => $links->paginate(getPaginationLimit()),
'route' => $request->getBaseUrl(),
'orderBy' => $request->input('orderBy', 'created_at'),
'orderDir' => $request->input('orderDir', 'desc'),