diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index 3c435c9c..cb6b3457 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -27,14 +27,15 @@ class Install extends Command # Only run these if we're doing an initial install if(!$this->option('update')) { + $this->writeLocalConfig(); $this->initialData(); } } /** - * 1. Setup the database and run the migrations - * Only call the database creation if we're not - * explicitly trying to upgrade + * Setup the database and run the migrations + * Only call the database creation if we're not + * explicitly trying to upgrade */ protected function setupDatabase() { @@ -49,7 +50,15 @@ class Install extends Command } /** - * 2. Set an initial airline and admin user/password + * Write a local config file + */ + protected function writeLocalConfig() + { + + } + + /** + * Set an initial airline and admin user/password */ protected function initialData() { diff --git a/app/Http/Controllers/Admin/DashboardController.php b/app/Http/Controllers/Admin/DashboardController.php index 53c80d13..773b289e 100644 --- a/app/Http/Controllers/Admin/DashboardController.php +++ b/app/Http/Controllers/Admin/DashboardController.php @@ -2,10 +2,19 @@ namespace App\Http\Controllers\Admin; +use App\Repositories\PirepRepository; use Illuminate\Http\Request; class DashboardController extends BaseController { + private $pirepRepo; + + public function __construct( + PirepRepository $pirepRepo + ) { + $this->pirepRepo = $pirepRepo; + } + /** * Display a listing of the Airlines. */ @@ -18,6 +27,7 @@ class DashboardController extends BaseController $feed = []; return view('admin.dashboard.index', [ 'feed' => $feed, + 'pending_pireps' => $this->pirepRepo->getPendingCount(), ]); } } diff --git a/app/Http/Controllers/Admin/PirepController.php b/app/Http/Controllers/Admin/PirepController.php index f66ff979..a73f1233 100644 --- a/app/Http/Controllers/Admin/PirepController.php +++ b/app/Http/Controllers/Admin/PirepController.php @@ -58,6 +58,26 @@ class PirepController extends BaseController ]); } + /** + * @param Request $request + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * @throws \Prettus\Repository\Exceptions\RepositoryException + */ + public function pending(Request $request) + { + $criterea = new RequestCriteria($request); + $this->pirepRepo->pushCriteria($criterea); + + $pireps = $this->pirepRepo + ->findWhere(['status' => config('enums.pirep_status.PENDING')]) + ->orderBy('created_at', 'desc') + ->paginate(); + + return view('admin.pireps.index', [ + 'pireps' => $pireps + ]); + } + /** * Show the form for creating a new Pirep. * @return Response diff --git a/app/Repositories/PirepRepository.php b/app/Repositories/PirepRepository.php index 0fa0f396..5df420f3 100644 --- a/app/Repositories/PirepRepository.php +++ b/app/Repositories/PirepRepository.php @@ -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; + } } diff --git a/resources/views/admin/components/infobox.blade.php b/resources/views/admin/components/infobox.blade.php index 8e4327c0..e3a88934 100644 --- a/resources/views/admin/components/infobox.blade.php +++ b/resources/views/admin/components/infobox.blade.php @@ -9,15 +9,23 @@
{{$type}}
- {{$pending}} pending + @if(isset($link)) + + @endif + {{$pending}} pending + @if(isset($link)) + + @endif