Convert recent pilots/pireps to widgets #127
This commit is contained in:
@@ -26,9 +26,6 @@ class DashboardController extends AppBaseController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$users = $this->userRepo->recent();
|
||||
$pireps = $this->pirepRepo->recent();
|
||||
|
||||
$last_pirep = null;
|
||||
$user = Auth::user();
|
||||
|
||||
@@ -38,8 +35,6 @@ class DashboardController extends AppBaseController
|
||||
|
||||
return $this->view('dashboard.index', [
|
||||
'user' => $user,
|
||||
'pireps' => $pireps,
|
||||
'users' => $users,
|
||||
'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']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user