Skip to content

Commit

Permalink
Update AdminMediaController, improve perf and use simple pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
dansup committed Jul 7, 2021
1 parent 4a30ff1 commit f2686ca
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/Http/Controllers/Admin/AdminMediaController.php
Expand Up @@ -27,6 +27,7 @@ public function media(Request $request)
],
'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')
Expand All @@ -42,7 +43,8 @@ public function media(Request $request)
$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'));
}

Expand All @@ -51,4 +53,4 @@ public function mediaShow(Request $request, $id)
$media = Media::findOrFail($id);
return view('admin.media.show', compact('media'));
}
}
}

0 comments on commit f2686ca

Please sign in to comment.