count/filtering of pending PIREPs
This commit is contained in:
@@ -27,14 +27,15 @@ class Install extends Command
|
|||||||
|
|
||||||
# Only run these if we're doing an initial install
|
# Only run these if we're doing an initial install
|
||||||
if(!$this->option('update')) {
|
if(!$this->option('update')) {
|
||||||
|
$this->writeLocalConfig();
|
||||||
$this->initialData();
|
$this->initialData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1. Setup the database and run the migrations
|
* Setup the database and run the migrations
|
||||||
* Only call the database creation if we're not
|
* Only call the database creation if we're not
|
||||||
* explicitly trying to upgrade
|
* explicitly trying to upgrade
|
||||||
*/
|
*/
|
||||||
protected function setupDatabase()
|
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()
|
protected function initialData()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,10 +2,19 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Repositories\PirepRepository;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class DashboardController extends BaseController
|
class DashboardController extends BaseController
|
||||||
{
|
{
|
||||||
|
private $pirepRepo;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
PirepRepository $pirepRepo
|
||||||
|
) {
|
||||||
|
$this->pirepRepo = $pirepRepo;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a listing of the Airlines.
|
* Display a listing of the Airlines.
|
||||||
*/
|
*/
|
||||||
@@ -18,6 +27,7 @@ class DashboardController extends BaseController
|
|||||||
$feed = [];
|
$feed = [];
|
||||||
return view('admin.dashboard.index', [
|
return view('admin.dashboard.index', [
|
||||||
'feed' => $feed,
|
'feed' => $feed,
|
||||||
|
'pending_pireps' => $this->pirepRepo->getPendingCount(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
* Show the form for creating a new Pirep.
|
||||||
* @return Response
|
* @return Response
|
||||||
|
|||||||
@@ -38,4 +38,20 @@ class PirepRepository extends BaseRepository implements CacheableInterface
|
|||||||
$pireps = $this->orderBy('created_at', 'desc')->findWhere($where)->all();
|
$pireps = $this->orderBy('created_at', 'desc')->findWhere($where)->all();
|
||||||
return $pireps;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,15 +9,23 @@
|
|||||||
<div class="col-xs-7">
|
<div class="col-xs-7">
|
||||||
<div class="numbers">
|
<div class="numbers">
|
||||||
<p>{{$type}}</p>
|
<p>{{$type}}</p>
|
||||||
{{$pending}} pending
|
@if(isset($link))
|
||||||
|
<a href="{!! @link !!}">
|
||||||
|
@endif
|
||||||
|
{{$pending}} pending
|
||||||
|
@if(isset($link))
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<hr>
|
<hr>
|
||||||
<div class="stats">
|
@if(isset($total))
|
||||||
<i class="ti-medall"></i> {{$total}} total
|
<div class="stats">
|
||||||
</div>
|
<i class="ti-medall"></i> {{$total}} total
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,25 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
|
|
||||||
<div class="row">
|
<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')
|
@component('admin.components.infobox')
|
||||||
@slot('icon', 'pe-7s-users')
|
@slot('icon', 'pe-7s-users')
|
||||||
@slot('type', 'Pilots')
|
@slot('type', 'Pilots')
|
||||||
@@ -20,25 +38,7 @@
|
|||||||
@slot('pending', 5)
|
@slot('pending', 5)
|
||||||
@slot('total', 60)
|
@slot('total', 60)
|
||||||
@endcomponent
|
@endcomponent
|
||||||
</div>
|
</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>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
@section('title', 'Pilot Reports')
|
@section('title', 'Pilot Reports')
|
||||||
@section('actions')
|
@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>View All</a></li>
|
||||||
<li><a href="{!! route('admin.pireps.index') !!}"><i class="ti-plus"></i>Pending</a></li>
|
|
||||||
@endsection
|
@endsection
|
||||||
@section('content')
|
@section('content')
|
||||||
@include('admin.pireps.table')
|
@include('admin.pireps.table')
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ Route::group([
|
|||||||
|
|
||||||
# pirep related routes
|
# pirep related routes
|
||||||
Route::resource('pireps', 'PirepController');
|
Route::resource('pireps', 'PirepController');
|
||||||
|
Route::match(['get'], 'pireps/pending', 'PirepController@pending');
|
||||||
Route::match(['post', 'put'], 'pireps/{id}/status', 'PirepController@status');
|
Route::match(['post', 'put'], 'pireps/{id}/status', 'PirepController@status');
|
||||||
|
|
||||||
Route::resource('pirepfields', 'PirepFieldController');
|
Route::resource('pirepfields', 'PirepFieldController');
|
||||||
|
|||||||
Reference in New Issue
Block a user