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
|
||||
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()
|
||||
{
|
||||
|
||||
@@ -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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user