phpvms/app/Widgets/LatestPilots.php
arthurpar06 820157d346
Optimization (#1508)
* Use eager loading in SubfleetRepository

* Remove useless queries from LiveMapController

* Use eager loading in LatestPilots

* Load page_links only in nav view

* Store settings in cache when env is production

* Style CI fix

* Store modules queries when env is prod

* Style CI fix

* Don't check env before forgetting settings or modules cache
2023-01-11 14:06:28 -06:00

32 lines
749 B
PHP

<?php
namespace App\Widgets;
use App\Contracts\Widget;
use App\Models\Enums\UserState;
use App\Repositories\UserRepository;
/**
* Show the latest pilots in a view
*/
class LatestPilots extends Widget
{
protected $config = [
'count' => 5,
];
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function run()
{
$userRepo = app(UserRepository::class);
$userRepo = $userRepo->with(['airline', 'home_airport'])->where('state', '!=', UserState::DELETED)->orderby('created_at', 'desc')->take($this->config['count'])->get();
return view('widgets.latest_pilots', [
'config' => $this->config,
'users' => $userRepo,
]);
}
}