Files
sibedas/app/Http/Controllers/Api/LackOfPotentialController.php
2025-08-20 00:23:30 +07:00

50 lines
2.0 KiB
PHP

<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\Advertisement;
use App\Models\Customer;
use App\Models\SpatialPlanning;
use Illuminate\Http\Request;
use App\Models\TourismBasedKBLI;
use App\Models\Tax;
class LackOfPotentialController extends Controller
{
public function count_lack_of_potential(){
try{
$total_reklame = Advertisement::count();
$total_pdam = Customer::count();
$total_tata_ruang = SpatialPlanning::count();
$total_tata_ruang_usaha = SpatialPlanning::where('building_function','like', '%usaha%')->count();
$total_tata_ruang_non_usaha = SpatialPlanning::where('building_function','not like', '%usaha%')->count();
$data_report_tourism = TourismBasedKBLI::all();
$data_pajak_reklame = Tax::where('tax_code','Reklame')->count();
$data_pajak_restoran = Tax::where('tax_code','Restoran')->count();
$data_pajak_hiburan = Tax::where('tax_code','Hiburan')->count();
$data_pajak_hotel = Tax::where('tax_code','Hotel')->count();
$data_pajak_parkir = Tax::where('tax_code','Parkir')->count();
return response()->json([
'total_reklame' => $total_reklame,
'total_pdam' => $total_pdam,
'total_tata_ruang' => $total_tata_ruang,
'total_tata_ruang_usaha' => $total_tata_ruang_usaha,
'total_tata_ruang_non_usaha' => $total_tata_ruang_non_usaha,
'data_report' => $data_report_tourism,
'data_pajak_reklame' => $data_pajak_reklame,
'data_pajak_restoran' => $data_pajak_restoran,
'data_pajak_hiburan' => $data_pajak_hiburan,
'data_pajak_hotel' => $data_pajak_hotel,
'data_pajak_parkir' => $data_pajak_parkir,
], 200);
}catch(\Exception $e){
return response()->json([
'message' => 'Error: '.$e->getMessage()
], 500);
}
}
}