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 [ $combine['PS_PROCESSING'], $combine['MS_WAREHOUSE_RECEIVING'], $combine['PS_SHIPPING'], $completedArray['COMPLETED'] ]; } }