diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 642e6d220..876ab2784 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -142,21 +142,17 @@ class AdminController extends Controller public function reports(Request $request) { + $this->validate($request, [ + 'filter' => 'nullable|string|in:all,open,closed' + ]); $filter = $request->input('filter'); - if(in_array($filter, ['open', 'closed'])) { - if($filter == 'open') { - $reports = Report::orderBy('created_at','desc') - ->whereNotNull('admin_seen') - ->paginate(10); - } else { - $reports = Report::orderBy('created_at','desc') - ->whereNull('admin_seen') - ->paginate(10); - } - } else { - $reports = Report::orderBy('created_at','desc') - ->paginate(10); - } + $reports = Report::orderBy('created_at','desc') + ->when($filter, function($q, $filter) { + return $filter == 'open' ? + $q->whereNull('admin_seen') : + $q->whereNotNull('admin_seen'); + }) + ->paginate(4); return view('admin.reports.home', compact('reports')); } diff --git a/resources/views/admin/reports/home.blade.php b/resources/views/admin/reports/home.blade.php index 569ee9d65..001c282e3 100644 --- a/resources/views/admin/reports/home.blade.php +++ b/resources/views/admin/reports/home.blade.php @@ -1,134 +1,75 @@ @extends('admin.partial.template-full') @section('section') -
-
-
-
-
- |
- # | -Reporter | -Type | -Reported | -Status | -Created | -|
---|---|---|---|---|---|---|---|
-
-
-
-
- |
- - - {{$report->id}} - - - | -{{$report->reporter->username}} | -{{$report->type}} | -{{str_limit($report->reported()->url(), 25)}} | - @if(!$report->admin_seen) -Unresolved | - @else -Resolved | - @endif -{{$report->created_at->diffForHumans(null, true, true, true)}} | -
{{$report->type}} # {{$report->id}}
- -No reports found
+