Show count of pending pilot registrations; pagination

This commit is contained in:
Nabeel Shahzad
2017-12-22 14:48:15 -06:00
parent 7103278bb8
commit 50ede116ca
9 changed files with 70 additions and 52 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Repositories;
use App\Models\Enums\PirepState;
use App\Models\Pirep;
use App\Models\User;
use App\Repositories\Traits\CacheableRepository;
@@ -15,6 +16,7 @@ class PirepRepository extends BaseRepository implements CacheableInterface
'user_id',
'flight_id',
'status',
'state',
];
public function model()
@@ -46,7 +48,10 @@ class PirepRepository extends BaseRepository implements CacheableInterface
*/
public function getPendingCount(User $user = null)
{
$where = [];
$where = [
'state' => PirepState::PENDING,
];
if ($user !== null) {
$where['user_id'] = $user->id;
}