|
|
@@ -6,6 +6,7 @@ use App\Models\Member;
|
|
6
|
6
|
use App\Models\Mutation;
|
|
7
|
7
|
use App\Models\TypeMember;
|
|
8
|
8
|
use App\Models\TypeVehicle;
|
|
|
9
|
+use App\Models\User;
|
|
9
|
10
|
use App\Services\MutationService;
|
|
10
|
11
|
use Carbon\Carbon;
|
|
11
|
12
|
use Illuminate\Http\Request;
|
|
|
@@ -20,13 +21,15 @@ class DashboardController extends Controller
|
|
20
|
21
|
*/
|
|
21
|
22
|
public function __invoke(Request $request)
|
|
22
|
23
|
{
|
|
23
|
|
- $member = Member::get();
|
|
|
24
|
+ $members = Member::get();
|
|
24
|
25
|
|
|
25
|
|
- $typeMember = TypeMember::get();
|
|
|
26
|
+ $typeMembers = TypeMember::get();
|
|
26
|
27
|
|
|
27
|
|
- $typeVehicle = TypeVehicle::get();
|
|
|
28
|
+ $typeVehicles = TypeVehicle::get();
|
|
28
|
29
|
|
|
29
|
|
- $mutation = Mutation::whereYear('created_at', date('Y'))
|
|
|
30
|
+ $users = User::get();
|
|
|
31
|
+
|
|
|
32
|
+ $mutations = Mutation::whereYear('created_at', date('Y'))
|
|
30
|
33
|
->get()
|
|
31
|
34
|
->groupBy([
|
|
32
|
35
|
fn($mutation) => $mutation->type,
|
|
|
@@ -41,31 +44,49 @@ class DashboardController extends Controller
|
|
41
|
44
|
// 'amount' => ...,
|
|
42
|
45
|
// 'amountLabel' => ...,
|
|
43
|
46
|
// 'value' => ...,
|
|
|
47
|
+ // 'roleId' => [...,...]
|
|
44
|
48
|
// ],
|
|
45
|
49
|
[
|
|
46
|
50
|
'title' => __('words.member'),
|
|
47
|
51
|
'icon' => 'pi pi-id-card',
|
|
48
|
|
- 'amount' => $member->count(),
|
|
|
52
|
+ 'amount' => $members->count(),
|
|
49
|
53
|
'amountLabel' => __('words.total'),
|
|
|
54
|
+ 'roleId' => [3],
|
|
50
|
55
|
],
|
|
51
|
56
|
[
|
|
52
|
57
|
'title' => __('words.type_member'),
|
|
53
|
58
|
'icon' => 'pi pi-id-card',
|
|
54
|
|
- 'amount' => $typeMember->count(),
|
|
|
59
|
+ 'amount' => $typeMembers->count(),
|
|
55
|
60
|
'amountLabel' => __('words.total'),
|
|
|
61
|
+ 'roleId' => [2],
|
|
56
|
62
|
],
|
|
57
|
63
|
[
|
|
58
|
64
|
'title' => __('words.type_vehicle'),
|
|
59
|
65
|
'icon' => 'pi pi-car',
|
|
60
|
|
- 'amount' => $typeVehicle->count(),
|
|
|
66
|
+ 'amount' => $typeVehicles->count(),
|
|
|
67
|
+ 'amountLabel' => __('words.total'),
|
|
|
68
|
+ 'roleId' => [3],
|
|
|
69
|
+ ],
|
|
|
70
|
+ [
|
|
|
71
|
+ 'title' => __('words.user'),
|
|
|
72
|
+ 'icon' => 'pi pi-user',
|
|
|
73
|
+ 'amount' => $users->count(),
|
|
61
|
74
|
'amountLabel' => __('words.total'),
|
|
|
75
|
+ 'roleId' => [1],
|
|
62
|
76
|
],
|
|
63
|
77
|
],
|
|
64
|
78
|
'barStatistics' => [
|
|
|
79
|
+ // [
|
|
|
80
|
+ // 'title' => ...,
|
|
|
81
|
+ // 'description' => ...,
|
|
|
82
|
+ // 'data' => ...,
|
|
|
83
|
+ // 'roleId' => [..., ...],
|
|
|
84
|
+ // ],
|
|
65
|
85
|
[
|
|
66
|
86
|
'title' => __('words.mutation_statistic'),
|
|
67
|
87
|
'description' => __('words.per_year') . ' ' . date('Y'),
|
|
68
|
|
- 'data' => (new MutationService)->statistic($mutation),
|
|
|
88
|
+ 'data' => (new MutationService)->statistic($mutations),
|
|
|
89
|
+ 'roleId' => [2, 3],
|
|
69
|
90
|
],
|
|
70
|
91
|
],
|
|
71
|
92
|
]);
|