mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-08-19 04:24:00 +00:00
45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: ayen
|
|
* Date: 19/03/2019
|
|
* Time: 9:42 AM
|
|
*/
|
|
|
|
namespace App\Classes\Modules\ControllersLogic\Dashboard;
|
|
|
|
use App\Models\Company;
|
|
use App\Models\Order;
|
|
use Carbon\Carbon;
|
|
|
|
class ActiveCustomerReportLogic
|
|
{
|
|
/* @var Order */
|
|
private $orderRepository;
|
|
|
|
/* @var Company */
|
|
private $companiesRepository;
|
|
|
|
/**
|
|
* ActiveCustomerReportLogic constructor.
|
|
* @param Order $orderRepository
|
|
* @param Company $companiesRepository
|
|
*/
|
|
public function __construct(Order $orderRepository, Company $companiesRepository)
|
|
{
|
|
$this->orderRepository = $orderRepository;
|
|
$this->companiesRepository = $companiesRepository;
|
|
}
|
|
|
|
|
|
public function execute() {
|
|
$active = $this->orderRepository->whereYear('created_at', '=', Carbon::now()->year)->whereMonth('created_at', '=', Carbon::now()->month)->orderBy('company_id')->get()->groupBy('company_id');
|
|
$company = $this->companiesRepository->count();
|
|
|
|
if ($company > $active->count()) $company -= $active->count();
|
|
else $company = $active->count() - $company;
|
|
|
|
return [$active->count(), $company];
|
|
|
|
}
|
|
} |