Show count of pending pilot registrations; pagination
This commit is contained in:
@@ -2,17 +2,21 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Repositories\PirepRepository;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
use App\Repositories\PirepRepository;
|
||||||
|
use App\Repositories\UserRepository;
|
||||||
|
|
||||||
class DashboardController extends BaseController
|
class DashboardController extends BaseController
|
||||||
{
|
{
|
||||||
private $pirepRepo;
|
private $pirepRepo, $userRepo;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
PirepRepository $pirepRepo
|
PirepRepository $pirepRepo,
|
||||||
|
UserRepository $userRepo
|
||||||
) {
|
) {
|
||||||
$this->pirepRepo = $pirepRepo;
|
$this->pirepRepo = $pirepRepo;
|
||||||
|
$this->userRepo = $userRepo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,6 +32,7 @@ class DashboardController extends BaseController
|
|||||||
return view('admin.dashboard.index', [
|
return view('admin.dashboard.index', [
|
||||||
'feed' => $feed,
|
'feed' => $feed,
|
||||||
'pending_pireps' => $this->pirepRepo->getPendingCount(),
|
'pending_pireps' => $this->pirepRepo->getPendingCount(),
|
||||||
|
'pending_users' => $this->userRepo->getPendingCount(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,19 +36,15 @@ class UserController extends BaseController
|
|||||||
$this->userRepo = $userRepo;
|
$this->userRepo = $userRepo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Display a listing of the User.
|
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
* @return Response
|
|
||||||
*/
|
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$this->userRepo->pushCriteria(new RequestCriteria($request));
|
$this->userRepo->pushCriteria(new RequestCriteria($request));
|
||||||
$Users = $this->userRepo->all();
|
$users = $this->userRepo
|
||||||
|
->orderBy('created_at', 'desc')
|
||||||
|
->paginate();
|
||||||
|
|
||||||
return view('admin.users.index', [
|
return view('admin.users.index', [
|
||||||
'users' => $Users,
|
'users' => $users,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
|
use App\Models\Enums\PirepState;
|
||||||
use App\Models\Pirep;
|
use App\Models\Pirep;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Repositories\Traits\CacheableRepository;
|
use App\Repositories\Traits\CacheableRepository;
|
||||||
@@ -15,6 +16,7 @@ class PirepRepository extends BaseRepository implements CacheableInterface
|
|||||||
'user_id',
|
'user_id',
|
||||||
'flight_id',
|
'flight_id',
|
||||||
'status',
|
'status',
|
||||||
|
'state',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function model()
|
public function model()
|
||||||
@@ -46,7 +48,10 @@ class PirepRepository extends BaseRepository implements CacheableInterface
|
|||||||
*/
|
*/
|
||||||
public function getPendingCount(User $user = null)
|
public function getPendingCount(User $user = null)
|
||||||
{
|
{
|
||||||
$where = [];
|
$where = [
|
||||||
|
'state' => PirepState::PENDING,
|
||||||
|
];
|
||||||
|
|
||||||
if ($user !== null) {
|
if ($user !== null) {
|
||||||
$where['user_id'] = $user->id;
|
$where['user_id'] = $user->id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
|
use App\Models\Enums\PilotState;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Repositories\Traits\CacheableRepository;
|
use App\Repositories\Traits\CacheableRepository;
|
||||||
use Prettus\Repository\Contracts\CacheableInterface;
|
use Prettus\Repository\Contracts\CacheableInterface;
|
||||||
@@ -14,10 +15,25 @@ class UserRepository extends BaseRepository implements CacheableInterface
|
|||||||
'email' => 'like',
|
'email' => 'like',
|
||||||
'home_airport_id',
|
'home_airport_id',
|
||||||
'curr_airport_id',
|
'curr_airport_id',
|
||||||
|
'state'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function model()
|
public function model()
|
||||||
{
|
{
|
||||||
return User::class;
|
return User::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of PIREPs that are pending
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getPendingCount()
|
||||||
|
{
|
||||||
|
$where = [
|
||||||
|
'state' => PilotState::PENDING,
|
||||||
|
];
|
||||||
|
|
||||||
|
$users = $this->orderBy('created_at', 'desc')->findWhere($where)->count();
|
||||||
|
return $users;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ return [
|
|||||||
|
|
||||||
|
|
||||||
# ENUMS
|
# ENUMS
|
||||||
|
'PilotState' => App\Models\Enums\PilotState::class,
|
||||||
'PirepSource' => App\Models\Enums\PirepSource::class,
|
'PirepSource' => App\Models\Enums\PirepSource::class,
|
||||||
'PirepState' => App\Models\Enums\PirepState::class,
|
'PirepState' => App\Models\Enums\PirepState::class,
|
||||||
'PirepStatus' => App\Models\Enums\PirepStatus::class,
|
'PirepStatus' => App\Models\Enums\PirepStatus::class,
|
||||||
|
|||||||
@@ -10,11 +10,11 @@
|
|||||||
<div class="numbers">
|
<div class="numbers">
|
||||||
<p>{{$type}}</p>
|
<p>{{$type}}</p>
|
||||||
@if(isset($link))
|
@if(isset($link))
|
||||||
<a href="{!! @link !!}">
|
<a href="{!! $link !!}">
|
||||||
@endif
|
@endif
|
||||||
{{$pending}} pending
|
{{$pending}} pending
|
||||||
@if(isset($link))
|
@if(isset($link))
|
||||||
</a>
|
</a>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,45 +4,31 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-7">
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-6">
|
|
||||||
@component('admin.components.infobox')
|
|
||||||
@slot('icon', 'pe-7s-users')
|
|
||||||
@slot('type', 'Pilots')
|
|
||||||
@slot('pending', 5)
|
|
||||||
@slot('total', 60)
|
|
||||||
@endcomponent
|
|
||||||
|
|
||||||
@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-6">
|
|
||||||
@component('admin.components.infobox')
|
|
||||||
@slot('icon', 'pe-7s-users')
|
|
||||||
@slot('type', 'Pilots')
|
|
||||||
@slot('pending', 5)
|
|
||||||
@slot('total', 60)
|
|
||||||
@endcomponent
|
|
||||||
|
|
||||||
@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>
|
|
||||||
|
|
||||||
@include('admin.dashboard.announcements')
|
@include('admin.dashboard.announcements')
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-5">
|
||||||
|
@component('admin.components.infobox')
|
||||||
|
@slot('icon', 'pe-7s-users')
|
||||||
|
@slot('type', 'Pilots')
|
||||||
|
@slot('pending', $pending_users)
|
||||||
|
@slot('link', route('admin.users.index').'?search=state:0')
|
||||||
|
@endcomponent
|
||||||
|
|
||||||
|
@component('admin.components.infobox')
|
||||||
|
@slot('icon', 'pe-7s-cloud-upload')
|
||||||
|
@slot('type', 'PIREPs')
|
||||||
|
@slot('pending', $pending_pireps)
|
||||||
|
@slot('link', route('admin.pireps.index').'?search=state:0')
|
||||||
|
@endcomponent
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
@include('admin.dashboard.pirep_chart')
|
{{--@include('admin.dashboard.pirep_chart')--}}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{--<div class="col-md-3 col-sm-6 col-xs-12">
|
{{--<div class="col-md-3 col-sm-6 col-xs-12">
|
||||||
|
|||||||
@@ -13,5 +13,11 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
@include('admin.users.table')
|
@include('admin.users.table')
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 text-center">
|
||||||
|
{{ $users->links('admin.pagination.default') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,14 @@
|
|||||||
<td>{!! $user->name !!}</td>
|
<td>{!! $user->name !!}</td>
|
||||||
<td>{!! $user->email !!}</td>
|
<td>{!! $user->email !!}</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
@if($user->active == 1)
|
@if($user->state == PilotState::ACTIVE)
|
||||||
<span class="label label-success">Active</span>
|
<span class="label label-success">
|
||||||
|
@elseif($user->state == PilotState::PENDING)
|
||||||
|
<span class="label label-warning">
|
||||||
@else
|
@else
|
||||||
<span class="label label-default">Inactive</span>
|
<span class="label label-default">
|
||||||
@endif
|
@endif
|
||||||
|
{!! PilotState::label($user->state) !!}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
{!! Form::open(['route' => ['admin.users.destroy', $user->id], 'method' => 'delete']) !!}
|
{!! Form::open(['route' => ['admin.users.destroy', $user->id], 'method' => 'delete']) !!}
|
||||||
|
|||||||
Reference in New Issue
Block a user