|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* NOTICE OF LICENSE |
|
5
|
|
|
* |
|
6
|
|
|
* Part of the Rinvex Fort Package. |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to The MIT License (MIT) |
|
9
|
|
|
* that is bundled with this package in the LICENSE file. |
|
10
|
|
|
* |
|
11
|
|
|
* Package: Rinvex Fort Package |
|
12
|
|
|
* License: The MIT License (MIT) |
|
13
|
|
|
* Link: https://rinvex.com |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace Rinvex\Fort\Http\Controllers\Backend; |
|
17
|
|
|
|
|
18
|
|
|
use DB; |
|
19
|
|
|
use Carbon\Carbon; |
|
20
|
|
|
use Rinvex\Fort\Http\Controllers\AuthorizedController; |
|
21
|
|
|
|
|
22
|
|
|
class DashboardController extends AuthorizedController |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* Show the dashboard home. |
|
26
|
|
|
* |
|
27
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
|
|
28
|
|
|
*/ |
|
29
|
|
|
public function home() |
|
30
|
|
|
{ |
|
31
|
|
|
$abilityRepository = app('rinvex.fort.ability'); |
|
32
|
|
|
$roleRepository = app('rinvex.fort.role'); |
|
33
|
|
|
$userRepository = app('rinvex.fort.user'); |
|
34
|
|
|
|
|
35
|
|
|
// Get recent registered users |
|
36
|
|
|
$limit = config('rinvex.fort.backend.items_per_dashboard'); |
|
37
|
|
|
$users = $userRepository->orderBy('created_at', 'desc')->limit($limit)->findAll(); |
|
38
|
|
|
|
|
39
|
|
|
// Get statistics |
|
40
|
|
|
$stats = [ |
|
41
|
|
|
'abilities' => $abilityRepository->count(), |
|
42
|
|
|
'roles' => $roleRepository->count(), |
|
43
|
|
|
'users' => $userRepository->count(), |
|
44
|
|
|
]; |
|
45
|
|
|
|
|
46
|
|
|
// Get online users |
|
47
|
|
|
$onlineInterval = Carbon::now()->subMinutes(config('rinvex.fort.online.interval')); |
|
48
|
|
|
$persistences = app('rinvex.fort.persistence')->groupBy(['user_id']) |
|
49
|
|
|
->with(['user']) |
|
50
|
|
|
->where('attempt', '=', 0) |
|
51
|
|
|
->where('updated_at', '>', $onlineInterval) |
|
52
|
|
|
->get(['user_id', DB::raw('MAX(updated_at) as updated_at')]); |
|
53
|
|
|
|
|
54
|
|
|
return view('rinvex.fort::backend.dashboard.home', compact('users', 'persistences', 'stats')); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.