phpvms/app/Widgets/LatestPilots.php

32 lines
714 B
PHP
Raw Normal View History

<?php
namespace App\Widgets;
use App\Contracts\Widget;
use App\Models\Enums\UserState;
use App\Repositories\UserRepository;
2018-02-21 12:33:09 +08:00
/**
* 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,
]);
}
}