pagination for pireps (admin)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user