Files
izyim/app/Classes/Modules/ControllersLogic/Dashboard/OrdersStatusReportLogic.php
T
2019-04-12 19:25:20 +08:00

38 lines
1.2 KiB
PHP

<?php
namespace App\Classes\Modules\ControllersLogic\Dashboard;
use App\Models\Order;
class OrdersStatusReportLogic
{
/* @var Order */
private $repository;
/**
* OrderTypeReportLogic constructor.
* @param Order $repository
*/
public function __construct(Order $repository)
{
$this->repository = $repository;
}
public function execute() {
$status = $this->repository->whereNotNull('current_step')->get()->groupBy('current_step');
$completed = $this->repository->whereNull('current_step')->where('complete', '=' , 1)->get();
$statusMap = $status->map(function ($item) {
return collect($item)->count();
})->toArray();
$completedArray = ["COMPLETED" => $completed->count()];
$combine = $statusMap + $completedArray;
return [
(isset($combine['PS_PROCESSING'])) ? $combine['PS_PROCESSING'] : 0,
(isset($combine['MS_WAREHOUSE_RECEIVING'])) ? $combine['MS_WAREHOUSE_RECEIVING'] : 0,
(isset($combine['PS_SHIPPING'])) ? $combine['PS_SHIPPING'] : 0,
(isset($combine['COMPLETED'])) ? $combine['COMPLETED'] : 0
];
}
}