diff --git a/app/Http/Controllers/TorrentHistoryController.php b/app/Http/Controllers/TorrentHistoryController.php index feff9911dc..875dc7ea74 100644 --- a/app/Http/Controllers/TorrentHistoryController.php +++ b/app/Http/Controllers/TorrentHistoryController.php @@ -19,17 +19,23 @@ use App\Models\History; use App\Models\Scopes\ApprovedScope; use App\Models\Torrent; +use Illuminate\Http\Request; class TorrentHistoryController extends Controller { /** * Display History Of A Torrent. */ - public function index(int $id): \Illuminate\Contracts\View\Factory|\Illuminate\View\View + public function index(int $id, Request $request): \Illuminate\Contracts\View\Factory|\Illuminate\View\View { return view('torrent.history', [ 'torrent' => Torrent::withoutGlobalScope(ApprovedScope::class)->findOrFail($id), - 'histories' => History::with(['user'])->where('torrent_id', '=', $id)->latest()->get(), + 'histories' => History::query() + ->with(['user']) + ->where('torrent_id', '=', $id) + ->orderByRaw('user_id = ? DESC', [$request->user()->id]) + ->latest() + ->get(), ]); } } diff --git a/app/Http/Controllers/TorrentPeerController.php b/app/Http/Controllers/TorrentPeerController.php index b38dea6d7d..679dd21af0 100644 --- a/app/Http/Controllers/TorrentPeerController.php +++ b/app/Http/Controllers/TorrentPeerController.php @@ -19,13 +19,14 @@ use App\Models\Peer; use App\Models\Scopes\ApprovedScope; use App\Models\Torrent; +use Illuminate\Http\Request; class TorrentPeerController extends Controller { /** * Display Peers Of A Torrent. */ - public function index(int $id): \Illuminate\Contracts\View\Factory|\Illuminate\View\View + public function index(int $id, Request $request): \Illuminate\Contracts\View\Factory|\Illuminate\View\View { $torrent = Torrent::withoutGlobalScope(ApprovedScope::class)->findOrFail($id); @@ -36,6 +37,7 @@ public function index(int $id): \Illuminate\Contracts\View\Factory|\Illuminate\V ->select(['torrent_id', 'user_id', 'uploaded', 'downloaded', 'left', 'port', 'agent', 'created_at', 'updated_at', 'seeder', 'active', 'visible', 'connectable']) ->selectRaw('INET6_NTOA(ip) as ip') ->where('torrent_id', '=', $id) + ->orderByRaw('user_id = ? DESC', [$request->user()->id]) ->orderByDesc('active') ->orderByDesc('seeder') ->get()