count/filtering of pending PIREPs

This commit is contained in:
Nabeel Shahzad
2017-12-03 10:55:01 -06:00
parent 4c8fca39eb
commit 83cc5111b6
8 changed files with 93 additions and 29 deletions

View File

@@ -38,4 +38,20 @@ class PirepRepository extends BaseRepository implements CacheableInterface
$pireps = $this->orderBy('created_at', 'desc')->findWhere($where)->all();
return $pireps;
}
/**
* Number of PIREPs that are pending
* @param User|null $user
* @return mixed
*/
public function getPendingCount(User $user = null)
{
$where = [];
if ($user !== null) {
$where['user_id'] = $user->id;
}
$pireps = $this->orderBy('created_at', 'desc')->findWhere($where)->count();
return $pireps;
}
}