Вход Регистрация
Файл: src/app/Http/Controllers/PagesController.php
Строк: 108
<?php 
namespace AppHttpControllers;
use 
AppHttpControllersController;
use 
AppModelsCompanies;
use 
AppModelsInvoices;
use 
AppModelsSettings;
use 
CarbonCarbon;
use 
DB;
class 
PagesController extends Controller{
    public function 
getDashboard(){
        
// This Mount Expected - Due Amount
        // This Mount Paid
        // Total Invoice
        // Client Number
        
$CurrencyID Settings::findOrFail(1)->CurrencyID;
        
$MonthlyExpected number_format(Invoices::where("CurrencyID",$CurrencyID)->whereDate("DueDate",">=",CarbonCarbon::today()->subDays(30)->toDateString())->get()->sum("Total"));
        
$MonthlyPaid number_format(Invoices::where("CurrencyID",$CurrencyID)->whereDate("DueDate",">=",CarbonCarbon::today()->subDays(30)->toDateString())->where("Status","=","Paid")->get()->sum("Total"));
        
$DueAmount Invoices::where("CurrencyID",$CurrencyID)->whereDate("DueDate",">=",CarbonCarbon::today()->subDays(30)->toDateString())->where("Status","=","Pending")->get()->count();
        
$TotalClient Companies::get()->count();

        
$DelayedInvoices Invoices::where("CurrencyID",$CurrencyID)->whereDate("DueDate","<=",CarbonCarbon::today())->orderBy("DueDate","DESC")->where("Status","!=","Paid")->paginate(10);
        
$SoonInvoices Invoices::where("CurrencyID",$CurrencyID)->whereDate("DueDate",">",CarbonCarbon::today())->orderBy("DueDate","DESC")->where("Status","=","Pending")->paginate(10);

        
$Companies Companies::select(['Companies.CompanyID''Companies.Title',DB::raw('COUNT(Invoices.InvoiceID) as TotalInvoice')])->join('Invoices''Invoices.InvoiceID''=''Companies.CompanyID')
            ->
groupBy('Invoices.CompanyID')->orderBy("TotalInvoice","DESC")->take(7)
            ->
get();
        return 
view('layouts.dashboard',compact('MonthlyExpected','MonthlyPaid','DueAmount','TotalClient','DelayedInvoices','SoonInvoices','Companies'));
    }
    public function 
getYearlyInvoices(){
        
$Invoices Invoices::select(["Total as value","DueDate as date","Status"])->whereDate("DueDate",">=",Carbon::now()->subDays(370)->toDateString())->where("Status","=","Paid")->get();
        return 
response()->json($Invoices);
    }
}
?>
Онлайн: 3
Реклама