pagination for pireps (admin)

This commit is contained in:
Nabeel Shahzad 2017-12-01 10:44:35 -06:00
parent e1b0b92f83
commit 8509daab35
4 changed files with 26 additions and 3 deletions

View File

@ -46,7 +46,7 @@ class PirepController extends BaseController
$pireps = $this->pirepRepo $pireps = $this->pirepRepo
->orderBy('created_at', 'desc') ->orderBy('created_at', 'desc')
->all(); ->paginate();
return view('admin.pireps.index', [ return view('admin.pireps.index', [
'pireps' => $pireps 'pireps' => $pireps

View File

@ -3,6 +3,7 @@
namespace App\Repositories; namespace App\Repositories;
use App\Models\Pirep; use App\Models\Pirep;
use App\Models\User;
class PirepRepository extends BaseRepository class PirepRepository extends BaseRepository
{ {
@ -20,4 +21,21 @@ class PirepRepository extends BaseRepository
{ {
return Pirep::class; 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;
}
} }

View File

@ -22,7 +22,6 @@
<div class="col-12 text-center"> <div class="col-12 text-center">
{{ $flights->links('admin.pagination.default') }} {{ $flights->links('admin.pagination.default') }}
</div> </div>
</div> </div>
@endsection @endsection

View File

@ -3,6 +3,12 @@
@section('title', 'Pilot Reports') @section('title', 'Pilot Reports')
@section('content') @section('content')
@include('admin.pireps.table') @include('admin.pireps.table')
<div class="row">
<div class="col-12 text-center">
{{ $pireps->links('admin.pagination.default') }}
</div>
</div>
@endsection @endsection