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

@@ -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;
}
}