| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
-
- namespace App\Http\Controllers;
-
- use App\Models\Member;
- use App\Models\Mutation;
- use App\Models\TopUp;
- use App\Models\TypeMember;
- use App\Models\TypeVehicle;
- use App\Services\MutationService;
- use App\Services\TopUpService;
- use Carbon\Carbon;
- use Illuminate\Http\Request;
-
- class DashboardController extends Controller
- {
- /**
- * Handle the incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\Response
- */
- public function __invoke(Request $request)
- {
- $member = Member::get();
-
- $typeMember = TypeMember::get();
-
- $typeVehicle = TypeVehicle::get();
-
- $mutation = Mutation::whereYear('created_at', date('Y'))
- ->get()
- ->groupBy([
- fn($mutation) => $mutation->type,
- fn($mutation) => Carbon::parse($mutation->getRawOriginal('created_at'))->format('M'),
- ]);
-
- $topUp = TopUp::get()->groupBy('member_id');
- return inertia('home/Index.vue', [
- 'cardStatistics' => [
- // [
- // 'title' => ...,
- // 'icon' => ...',
- // 'amount' => ...,
- // 'amountLabel' => ...,
- // 'value' => ...,
- // ],
- [
- 'title' => __('words.member'),
- 'icon' => 'pi pi-id-card',
- 'amount' => $member->count(),
- 'amountLabel' => __('words.total'),
- ],
- [
- 'title' => __('words.type_member'),
- 'icon' => 'pi pi-id-card',
- 'amount' => $typeMember->count(),
- 'amountLabel' => __('words.total'),
- ],
- [
- 'title' => __('words.type_vehicle'),
- 'icon' => 'pi pi-car',
- 'amount' => $typeVehicle->count(),
- 'amountLabel' => __('words.total'),
- ],
- ],
- 'barStatistics' => [
- [
- 'title' => __('words.mutation_statistic'),
- 'description' => __('words.per_year') . ' ' . date('Y'),
- 'data' => (new MutationService)->statistic($mutation),
- ],
- ],
- 'barHorizontalStatistics' => [
- [
- 'title' => __('words.top_up_rank'),
- 'description' => __('words.top_up_number_rank', ['number' => 5]),
- 'data' => (new TopUpService)->topUpRank($topUp),
- ],
- ],
- ]);
- }
- }
|