Convert recent pilots/pireps to widgets #127
This commit is contained in:
@@ -26,9 +26,6 @@ class DashboardController extends AppBaseController
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$users = $this->userRepo->recent();
|
|
||||||
$pireps = $this->pirepRepo->recent();
|
|
||||||
|
|
||||||
$last_pirep = null;
|
$last_pirep = null;
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
|
|
||||||
@@ -38,8 +35,6 @@ class DashboardController extends AppBaseController
|
|||||||
|
|
||||||
return $this->view('dashboard.index', [
|
return $this->view('dashboard.index', [
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'pireps' => $pireps,
|
|
||||||
'users' => $users,
|
|
||||||
'last_pirep' => $last_pirep,
|
'last_pirep' => $last_pirep,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
20
app/Widgets/BaseWidget.php
Normal file
20
app/Widgets/BaseWidget.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by IntelliJ IDEA.
|
||||||
|
* User: nshahzad
|
||||||
|
* Date: 1/8/18
|
||||||
|
* Time: 7:46 PM
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Widgets;
|
||||||
|
|
||||||
|
use Arrilot\Widgets\AbstractWidget;
|
||||||
|
|
||||||
|
class BaseWidget extends AbstractWidget
|
||||||
|
{
|
||||||
|
public function view(string $template, array $vars = [])
|
||||||
|
{
|
||||||
|
$tpl = 'layouts/' . config('phpvms.skin') . '/' . $template;
|
||||||
|
return view($tpl, $vars);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
app/Widgets/RecentPilots.php
Normal file
25
app/Widgets/RecentPilots.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Widgets;
|
||||||
|
|
||||||
|
use App\Repositories\UserRepository;
|
||||||
|
|
||||||
|
class RecentPilots extends BaseWidget
|
||||||
|
{
|
||||||
|
protected $config = [
|
||||||
|
'count' => 5,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$userRepo = app(UserRepository::class);
|
||||||
|
|
||||||
|
return $this->view('widgets.recent_pilots', [
|
||||||
|
'config' => $this->config,
|
||||||
|
'users' => $userRepo->recent($this->config['count']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
app/Widgets/RecentPireps.php
Normal file
25
app/Widgets/RecentPireps.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Widgets;
|
||||||
|
|
||||||
|
use App\Repositories\PirepRepository;
|
||||||
|
|
||||||
|
class RecentPireps extends BaseWidget
|
||||||
|
{
|
||||||
|
protected $config = [
|
||||||
|
'count' => 5,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$pirepRepo = app(PirepRepository::class);
|
||||||
|
|
||||||
|
return $this->view('widgets.recent_pireps', [
|
||||||
|
'config' => $this->config,
|
||||||
|
'pireps' => $pirepRepo->recent($this->config['count']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
22
config/laravel-widgets.php
Normal file
22
config/laravel-widgets.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
//'default_namespace' => 'App\Widgets',
|
||||||
|
|
||||||
|
'use_jquery_for_ajax_calls' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set Ajax widget middleware
|
||||||
|
*/
|
||||||
|
'route_middleware' => [],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Relative path from the base directory to a regular widget stub.
|
||||||
|
*/
|
||||||
|
'widget_stub' => 'vendor/arrilot/laravel-widgets/src/Console/stubs/widget.stub',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Relative path from the base directory to a plain widget stub.
|
||||||
|
*/
|
||||||
|
'widget_plain_stub' => 'vendor/arrilot/laravel-widgets/src/Console/stubs/widget_plain.stub',
|
||||||
|
];
|
||||||
@@ -72,51 +72,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
|
|
||||||
<div class="card">
|
{{ Widget::recentPireps() }}
|
||||||
<div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;">
|
|
||||||
Recent Reports
|
{{ Widget::recentPilots() }}
|
||||||
</div>
|
|
||||||
<div class="card-block">
|
|
||||||
<!-- Tab panes -->
|
|
||||||
<div class="tab-content">
|
|
||||||
<table>
|
|
||||||
@foreach($pireps as $p)
|
|
||||||
<tr>
|
|
||||||
<td style="padding-right: 10px;">
|
|
||||||
<span class="title">{!! $p->airline->code !!}</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{!! $p->dpt_airport_id !!}-
|
|
||||||
{!! $p->arr_airport_id !!}
|
|
||||||
{!! $p->aircraft->name !!}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
@endforeach
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card">
|
|
||||||
<div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;">
|
|
||||||
Newest Pilots
|
|
||||||
</div>
|
|
||||||
<div class="card-block">
|
|
||||||
<!-- Tab panes -->
|
|
||||||
<div class="tab-content">
|
|
||||||
<table>
|
|
||||||
@foreach($users as $u)
|
|
||||||
<tr>
|
|
||||||
<td style="padding-right: 10px;">
|
|
||||||
<span class="title">{!! $u->pilot_id !!}</span>
|
|
||||||
</td>
|
|
||||||
<td>{!! $u->name !!}</td>
|
|
||||||
</tr>
|
|
||||||
@endforeach
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<div class="card">
|
||||||
|
<div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;">
|
||||||
|
Newest Pilots
|
||||||
|
</div>
|
||||||
|
<div class="card-block">
|
||||||
|
<!-- Tab panes -->
|
||||||
|
<div class="tab-content">
|
||||||
|
<table>
|
||||||
|
@foreach($users as $u)
|
||||||
|
<tr>
|
||||||
|
<td style="padding-right: 10px;">
|
||||||
|
<span class="title">{!! $u->pilot_id !!}</span>
|
||||||
|
</td>
|
||||||
|
<td>{!! $u->name !!}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<div class="card">
|
||||||
|
<div class="nav nav-tabs" role="tablist" style="background: #067ec1; color: #FFF;">
|
||||||
|
Recent Reports
|
||||||
|
</div>
|
||||||
|
<div class="card-block">
|
||||||
|
<!-- Tab panes -->
|
||||||
|
<div class="tab-content">
|
||||||
|
<table>
|
||||||
|
@foreach($pireps as $p)
|
||||||
|
<tr>
|
||||||
|
<td style="padding-right: 10px;">
|
||||||
|
<span class="title">{!! $p->airline->code !!}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{!! $p->dpt_airport_id !!}-
|
||||||
|
{!! $p->arr_airport_id !!}
|
||||||
|
{!! $p->aircraft->name !!}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user