<?php

namespace App\Http\Controllers\Api;

use App\Models\Job;
use App\Models\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class DashboardController extends Controller
{
    public function index(){
        $data['jumlahUser'] = number_format(User::all()->count(), 0, '.', ',');
        $data['jumlahOwner'] = number_format(User::where('role', 2)->where('status', 2)->get()->count(), 0, ',', '.');
        $data['jumlahMaid'] = number_format(User::where('role', 3)->where('status', 2)->get()->count(), 0, ',', '.');
        $data['jumlahJob'] = number_format(Job::all()->count(), 0, ',', '.');
        $data['jumlahJobSelesai'] = number_format(Job::whereNotNull('recruit_id')->get()->count(), 0, ',', '.');

        $result['status'] = true;
        $result['message'] = "OK";
        $result['data'] = $data;
        return response($result);
    }
}
