From f2686cacd27066bdd5e0316bda649e3cd588ac0f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 6 Jul 2021 23:36:25 -0600 Subject: [PATCH] Update AdminMediaController, improve perf and use simple pagination --- app/Http/Controllers/Admin/AdminMediaController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Admin/AdminMediaController.php b/app/Http/Controllers/Admin/AdminMediaController.php index eb4bd93a8..da9c3b27e 100644 --- a/app/Http/Controllers/Admin/AdminMediaController.php +++ b/app/Http/Controllers/Admin/AdminMediaController.php @@ -27,6 +27,7 @@ trait AdminMediaController ], 'search' => 'nullable|string|min:1|max:20' ]); + if($request->filled('search')) { $profiles = Profile::where('username', 'like', '%'.$request->input('search').'%')->pluck('id')->toArray(); $media = Media::whereHas('status') @@ -42,7 +43,8 @@ trait AdminMediaController $media = MediaBlocklist::latest()->paginate(12); return view('admin.media.home', compact('media')); } - $media = Media::whereHas('status')->with('status')->orderby('id', 'desc')->paginate(12); + + $media = Media::whereNull('remote_url')->orderby('id', 'desc')->simplePaginate(12); return view('admin.media.home', compact('media')); } @@ -51,4 +53,4 @@ trait AdminMediaController $media = Media::findOrFail($id); return view('admin.media.show', compact('media')); } -} \ No newline at end of file +}