leftJoin('pbg_task_retributions', 'pbg_task.uuid', '=', 'pbg_task_retributions.pbg_task_uid') ->select( DB::raw('COUNT(DISTINCT pbg_task.id) as task_count'), DB::raw('SUM(pbg_task_retributions.nilai_retribusi_bangunan) as total_retribution') ) ->where(function ($query) { $query->where("pbg_task.function_type", "NOT LIKE", "sebagai tempat usaha%") ->orWhereNull("pbg_task.function_type"); }) ->first(); $taskCount = $businessData->task_count; $taskTotal = $businessData->total_retribution; $result = [ "count" => $taskCount, "series" => [$taskCount], "total" => $taskTotal ]; return $this->resSuccess($result); } public function nonBusinnessDocument(Request $request){ $businessData = DB::table('pbg_task') ->leftJoin('pbg_task_retributions', 'pbg_task.uuid', '=', 'pbg_task_retributions.pbg_task_uid') ->select( DB::raw('COUNT(DISTINCT pbg_task.id) as task_count'), DB::raw('SUM(pbg_task_retributions.nilai_retribusi_bangunan) as total_retribution') ) ->where(function ($query) { $query->where("pbg_task.function_type", "LIKE", "sebagai tempat usaha%"); }) ->first(); $taskCount = $businessData->task_count; $taskTotal = $businessData->total_retribution; $result = [ "count" => $taskCount, "series" => [$taskCount], "total" => $taskTotal ]; return $this->resSuccess($result); } public function allTaskDocuments(){ $query = DB::table('pbg_task') ->leftJoin('pbg_task_retributions', 'pbg_task.uuid', '=', 'pbg_task_retributions.pbg_task_uid') ->select( DB::raw('COUNT(DISTINCT pbg_task.id) as task_count'), DB::raw('SUM(pbg_task_retributions.nilai_retribusi_bangunan) as total_retribution') ) ->first(); $taskCount = $query->task_count; $taskTotal = $query->total_retribution; $result = [ "count" => $taskCount, "series" => [$taskCount], "total" => $taskTotal ]; return $this->resSuccess($result); } }