2018-01-09 09:53:55 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Widgets;
|
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
use App\Interfaces\Widget;
|
2018-05-30 00:04:28 +08:00
|
|
|
use App\Models\Enums\PirepState;
|
2018-01-09 09:53:55 +08:00
|
|
|
use App\Repositories\PirepRepository;
|
|
|
|
|
2018-02-21 12:33:09 +08:00
|
|
|
/**
|
|
|
|
* Show the latest PIREPs in a view
|
|
|
|
*/
|
2018-03-20 09:50:40 +08:00
|
|
|
class LatestPireps extends Widget
|
2018-01-09 09:53:55 +08:00
|
|
|
{
|
|
|
|
protected $config = [
|
|
|
|
'count' => 5,
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
|
|
*/
|
|
|
|
public function run()
|
|
|
|
{
|
|
|
|
$pirepRepo = app(PirepRepository::class);
|
|
|
|
|
2018-05-30 00:04:28 +08:00
|
|
|
$pireps = $pirepRepo
|
2018-09-04 20:02:16 +08:00
|
|
|
->with(['airline', 'aircraft'])
|
2018-05-30 00:04:28 +08:00
|
|
|
->whereNotInOrder('state', [
|
|
|
|
PirepState::CANCELLED,
|
|
|
|
PirepState::DRAFT,
|
2018-08-27 00:40:04 +08:00
|
|
|
PirepState::IN_PROGRESS,
|
2018-05-30 00:04:28 +08:00
|
|
|
], 'created_at', 'desc')
|
|
|
|
->recent($this->config['count']);
|
|
|
|
|
2018-03-12 07:00:42 +08:00
|
|
|
return view('widgets.latest_pireps', [
|
2018-01-09 09:53:55 +08:00
|
|
|
'config' => $this->config,
|
2018-05-30 00:04:28 +08:00
|
|
|
'pireps' => $pireps,
|
2018-01-09 09:53:55 +08:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|