2018-01-09 09:53:55 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Widgets;
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
use App\Contracts\Widget;
|
2021-05-03 20:46:21 +08:00
|
|
|
use App\Models\Enums\UserState;
|
2018-01-09 09:53:55 +08:00
|
|
|
use App\Repositories\UserRepository;
|
|
|
|
|
2018-02-21 12:33:09 +08:00
|
|
|
/**
|
|
|
|
* Show the latest pilots in a view
|
|
|
|
*/
|
2018-03-20 09:50:40 +08:00
|
|
|
class LatestPilots 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()
|
|
|
|
{
|
|
|
|
$userRepo = app(UserRepository::class);
|
2021-05-03 20:46:21 +08:00
|
|
|
$userRepo = $userRepo->where('state', '!=', UserState::DELETED)->orderby('created_at', 'desc')->take($this->config['count'])->get();
|
2018-01-09 09:53:55 +08:00
|
|
|
|
2018-03-12 07:00:42 +08:00
|
|
|
return view('widgets.latest_pilots', [
|
2018-01-09 09:53:55 +08:00
|
|
|
'config' => $this->config,
|
2021-05-03 20:46:21 +08:00
|
|
|
'users' => $userRepo,
|
2018-01-09 09:53:55 +08:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|