phpvms/app/Widgets/LatestPilots.php
B.Fatih KOZ 5094375e13
Fixes For GDPR/Deleted Users (#1164)
* Fix DeletedUsers being displayed at Homepage

Deleted users should not be displayed at homepage / newest pilots list. PR fixes that problem.

* Do Not Display Deleted Users with LatestPireps

As the main page, Latest Pilots widget should not display GDPR/Soft deleted users too.

* StyleFix
2021-05-03 08:46:21 -04:00

32 lines
714 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->where('state', '!=', UserState::DELETED)->orderby('created_at', 'desc')->take($this->config['count'])->get();
return view('widgets.latest_pilots', [
'config' => $this->config,
'users' => $userRepo,
]);
}
}