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

@@ -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()
{

View File

@@ -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(),
]);
}
}

View File

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

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

View File

@@ -9,15 +9,23 @@
<div class="col-xs-7">
<div class="numbers">
<p>{{$type}}</p>
{{$pending}} pending
@if(isset($link))
<a href="{!! @link !!}">
@endif
{{$pending}} pending
@if(isset($link))
</a>
@endif
</div>
</div>
</div>
<div class="footer">
<hr>
<div class="stats">
<i class="ti-medall"></i> {{$total}} total
</div>
@if(isset($total))
<div class="stats">
<i class="ti-medall"></i> {{$total}} total
</div>
@endif
</div>
</div>

View File

@@ -4,7 +4,25 @@
<div class="content">
<div class="row">
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="col-md-6">
@component('admin.components.infobox')
@slot('icon', 'pe-7s-users')
@slot('type', 'Pilots')
@slot('pending', 5)
@slot('total', 60)
@endcomponent
</div>
<div class="col-md-6">
@component('admin.components.infobox')
@slot('icon', 'pe-7s-cloud-upload')
@slot('type', 'PIREPs')
@slot('pending', $pending_pireps)
@slot('link', route('admin.pireps.index').'?search=status:0')
@endcomponent
</div>
{{--<div class="col-md-3 col-sm-6 col-xs-12">
@component('admin.components.infobox')
@slot('icon', 'pe-7s-users')
@slot('type', 'Pilots')
@@ -20,25 +38,7 @@
@slot('pending', 5)
@slot('total', 60)
@endcomponent
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
@component('admin.components.infobox')
@slot('icon', 'pe-7s-users')
@slot('type', 'Pilots')
@slot('pending', 5)
@slot('total', 60)
@endcomponent
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
@component('admin.components.infobox')
@slot('icon', 'pe-7s-cloud-upload')
@slot('type', 'PIREPs')
@slot('pending', 5)
@slot('total', 60)
@endcomponent
</div>
</div>--}}
</div>

View File

@@ -2,8 +2,8 @@
@section('title', 'Pilot Reports')
@section('actions')
<li><a href="{!! route('admin.pireps.index') !!}?search=status:0"><i class="ti-plus"></i>Pending</a></li>
<li><a href="{!! route('admin.pireps.index') !!}"><i class="ti-plus"></i>View All</a></li>
<li><a href="{!! route('admin.pireps.index') !!}"><i class="ti-plus"></i>Pending</a></li>
@endsection
@section('content')
@include('admin.pireps.table')

View File

@@ -36,6 +36,7 @@ Route::group([
# pirep related routes
Route::resource('pireps', 'PirepController');
Route::match(['get'], 'pireps/pending', 'PirepController@pending');
Route::match(['post', 'put'], 'pireps/{id}/status', 'PirepController@status');
Route::resource('pirepfields', 'PirepFieldController');