• File: DashboardController.php
  • Full Path: /var/www/amparoapi/app/Http/Controllers/DashboardController.php
  • Date Modified: 10/15/2021 5:48 PM
  • File size: 1.55 KB
  • MIME-type: text/x-php
  • Charset: utf-8
<?php

namespace App\Http\Controllers;

use App\Models\Company;
use App\Models\CustomerAccount;
use App\Models\CustomerCard;
use App\Models\Recharge;
use Illuminate\Http\Request;

class DashboardController extends Controller
{
    public function getGeneralDashboard()
    {
        $totalCards = CustomerCard::query()->count();
        $totalAccounts = CustomerAccount::query()->count();
        $totalCompanies = Company::query()->count();
        $totalRecharges = Recharge::query()->count();

        $totalAccountBalance = CustomerAccount::query()->sum('balance');

        $cActivos = CustomerCard::query()->where('status', '=', 'activo')->count();
        $cNeverUsed = CustomerCard::query()->where('session_status', '=', 0)->count();
        $canRechargeCards = CustomerCard::query()->where('can_recharge', '=', 0)->count();
        $canReceiveNotificationCards = CustomerCard::query()->where('can_receive_notification', '=', 1)->count();
        $canPayCards = CustomerCard::query()->where('can_pay', '=', 1)->count();


        return response()->json([
            'totalCards' => $totalCards,
            'activeCards' => $cActivos,
            'neverUsedCards' => $cNeverUsed,
            'canRechargeCards' => $canRechargeCards,
            'canPayCards' => $canPayCards,
            'canReceiveNotificationCards' => $canReceiveNotificationCards,
            'totalAccounts' => $totalAccounts,
            'totalCompanies' => $totalCompanies,
            'totalAccountBalance' => $totalAccountBalance,
            'totalRecharges' => $totalAccountBalance,
        ]);


    }
}