pagination for pireps (admin)
This commit is contained in:
parent
e1b0b92f83
commit
8509daab35
@ -46,7 +46,7 @@ class PirepController extends BaseController
|
||||
|
||||
$pireps = $this->pirepRepo
|
||||
->orderBy('created_at', 'desc')
|
||||
->all();
|
||||
->paginate();
|
||||
|
||||
return view('admin.pireps.index', [
|
||||
'pireps' => $pireps
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
<div class="col-12 text-center">
|
||||
{{ $flights->links('admin.pagination.default') }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
|
@ -3,6 +3,12 @@
|
||||
@section('title', 'Pilot Reports')
|
||||
|
||||
@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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user