<?php

namespace App\Http\Controllers\FCControllers;
use App\Models\fcmodels\AdminUser;
use Illuminate\Http\Request;
use Auth ;
use App\Models\fcmodels\AuditLog;
use EloquentBuilder;
use App\Models\fcmodels\Currency_Expenditure;
use App\Models\fcmodels\Ivr;
use App\Models\fcmodels\Bulksms;

class AdminController extends Controller
{
  
    // public function __construct()
    // {
    //     //defining our middleware for this controller
    //     $this->middleware('auth.admin');
    // }
    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        try
        {  
            $adminlogin =AdminUser::all();    
                    $query =AuditLog::take(500);
        $auditlogs=EloquentBuilder::to($query,request()->all())->get();
     // return response()->json($trans);
     $ivrcountnow = Ivr::whereDate('created_at',now())->count();
         //sms count today
        $smscount = Currency_Expenditure::whereDate('date_time',now())->count();
           return view('fcviews.admin-dashboard',compact('adminlogin','auditlogs','ivrcountnow','smscount'));
        }
        catch(Exception $e)
        {
            abort(500, $e->getMessage());   
        }
    }

}
