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') -
+

Reports

- - + + ALL - - + + OPEN + + + CLOSED -
- -
- -
-
- - - 0 - - items selected - - - - - Apply - - -
-
-@if(request()->input('layout') == 'list') - - - - - - - - - - - - - + @if($reports->count()) +
+
@foreach($reports as $report) -
- - - - - - @if(!$report->admin_seen) - - @else - - @endif - - - @endforeach - -
-
- - -
-
#ReporterTypeReportedStatusCreated
-
- - -
-
- - {{$report->id}} - - - {{$report->reporter->username}}{{$report->type}}{{str_limit($report->reported()->url(), 25)}}UnresolvedResolved{{$report->created_at->diffForHumans(null, true, true, true)}}
-@else -
- @foreach($reports as $report) -
-
- -
-@endif + @else +
+
+

No reports found

+
+
+ @endif +
{{$reports->appends(['layout'=>request()->layout, 'filter' => request()->filter])->links()}}
@@ -140,82 +81,14 @@ top: auto; bottom: auto; } + .media-avatar { + width:64px; + height:64px; + background:#e9ecef; + } @endpush @push('scripts') - @endpush \ No newline at end of file