1
0
Fork 0
forked from mirror/pixelfed

Update AdminController

This commit is contained in:
Daniel Supernault 2019-02-12 01:11:02 -07:00
parent 4eeb1f0247
commit f38bad4a9c
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -26,6 +26,7 @@ use App\Http\Controllers\Admin\{
AdminSettingsController
};
use App\Util\Lexer\PrettyNumber;
use Illuminate\Validation\Rule;
class AdminController extends Controller
{
@ -181,10 +182,47 @@ class AdminController extends Controller
public function profiles(Request $request)
{
$profiles = Profile::orderBy('id','desc')->paginate(10);
$this->validate($request, [
'search' => 'nullable|string|max:250',
'filter' => [
'nullable',
'string',
Rule::in(['id','username','statuses_count','followers_count','likes_count'])
],
'order' => [
'nullable',
'string',
Rule::in(['asc','desc'])
],
'layout' => [
'nullable',
'string',
Rule::in(['card','list'])
],
'limit' => 'nullable|integer|min:1|max:50'
]);
$search = $request->input('search');
$filter = $request->input('filter');
$order = $request->input('order') ?? 'desc';
$limit = $request->input('limit') ?? 12;
if($search) {
$profiles = Profile::where('username','like', "%$search%")->orderBy('id','desc')->paginate($limit);
} else if($filter && $order) {
$profiles = Profile::withCount(['likes','statuses','followers'])->orderBy($filter, $order)->paginate($limit);
} else {
$profiles = Profile::orderBy('id','desc')->paginate($limit);
}
return view('admin.profiles.home', compact('profiles'));
}
public function profileShow(Request $request, $id)
{
$profile = Profile::findOrFail($id);
$user = $profile->user;
return view('admin.profiles.edit', compact('profile', 'user'));
}
public function appsHome(Request $request)
{
$filter = $request->input('filter');