forked from mirror/pixelfed
Update AdminController
This commit is contained in:
parent
4eeb1f0247
commit
f38bad4a9c
1 changed files with 39 additions and 1 deletions
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue