diff --git a/app/Http/Controllers/Admin/PirepController.php b/app/Http/Controllers/Admin/PirepController.php index 5cffd276..ea7ac4ac 100644 --- a/app/Http/Controllers/Admin/PirepController.php +++ b/app/Http/Controllers/Admin/PirepController.php @@ -46,7 +46,7 @@ class PirepController extends BaseController $pireps = $this->pirepRepo ->orderBy('created_at', 'desc') - ->all(); + ->paginate(); return view('admin.pireps.index', [ 'pireps' => $pireps diff --git a/app/Repositories/PirepRepository.php b/app/Repositories/PirepRepository.php index d979b5d5..a67514df 100644 --- a/app/Repositories/PirepRepository.php +++ b/app/Repositories/PirepRepository.php @@ -3,6 +3,7 @@ namespace App\Repositories; use App\Models\Pirep; +use App\Models\User; class PirepRepository extends BaseRepository { @@ -20,4 +21,21 @@ class PirepRepository extends BaseRepository { return Pirep::class; } + + /** + * Get all the pending reports in order. Returns the Pirep + * model but you still need to call ->all() or ->paginate() + * @param User|null $user + * @return Pirep + */ + public function getPending(User $user=null) + { + $where = []; + if($user !== null) { + $where['user_id'] = $user->id; + } + + $pireps = $this->orderBy('created_at', 'desc')->findWhere($where)->all(); + return $pireps; + } } diff --git a/resources/views/admin/flights/index.blade.php b/resources/views/admin/flights/index.blade.php index 9e34fd81..99e49302 100644 --- a/resources/views/admin/flights/index.blade.php +++ b/resources/views/admin/flights/index.blade.php @@ -22,7 +22,6 @@
{{ $flights->links('admin.pagination.default') }}
- @endsection diff --git a/resources/views/admin/pireps/index.blade.php b/resources/views/admin/pireps/index.blade.php index 1622aac8..51b07c24 100644 --- a/resources/views/admin/pireps/index.blade.php +++ b/resources/views/admin/pireps/index.blade.php @@ -3,6 +3,12 @@ @section('title', 'Pilot Reports') @section('content') -@include('admin.pireps.table') + @include('admin.pireps.table') + +
+
+ {{ $pireps->links('admin.pagination.default') }} +
+
@endsection