phpvms/app/Widgets/LatestPireps.php

40 lines
868 B
PHP
Raw Normal View History

<?php
namespace App\Widgets;
use App\Interfaces\Widget;
2018-05-30 00:04:28 +08:00
use App\Models\Enums\PirepState;
use App\Repositories\PirepRepository;
2018-02-21 12:33:09 +08:00
/**
* Show the latest PIREPs in a view
* @package App\Widgets
*/
class LatestPireps extends Widget
{
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
->whereNotInOrder('state', [
PirepState::CANCELLED,
PirepState::DRAFT,
PirepState::IN_PROGRESS
], 'created_at', 'desc')
->recent($this->config['count']);
return view('widgets.latest_pireps', [
'config' => $this->config,
2018-05-30 00:04:28 +08:00
'pireps' => $pireps,
]);
}
}