From 5146dd0e84270b725e075d1183a0da7b98a466bd Mon Sep 17 00:00:00 2001 From: JokoPrasetio Date: Wed, 13 May 2026 14:34:07 +0700 Subject: [PATCH] fixing route external --- app/Http/Controllers/PitStopController.php | 69 ++++++++++++------- resources/views/auth/login.blade.php | 2 +- .../progress_external_detail.blade.php | 5 +- .../views/pitstop/progress_unit.blade.php | 7 +- .../pitstop/progress_unit_detail.blade.php | 2 +- routes/web.php | 3 + 6 files changed, 56 insertions(+), 32 deletions(-) diff --git a/app/Http/Controllers/PitStopController.php b/app/Http/Controllers/PitStopController.php index 3235e9b..ff9c630 100644 --- a/app/Http/Controllers/PitStopController.php +++ b/app/Http/Controllers/PitStopController.php @@ -37,7 +37,7 @@ class PitStopController extends Controller } public function pitstop(){ - $masterPitStop = MasterPitStopPraAkre::where('statusenabled', true)->get(); + $masterPitStop = MasterPitStopPraAkre::where('statusenabled', true)->orderBy('id', 'asc')->get(); $data = [ 'title' => 'PitStop', 'masterPitStop' => $masterPitStop @@ -76,8 +76,15 @@ class PitStopController extends Controller ]); } - public function progressExternalDetail(Request $request, $tipe) + public function progressExternalDetail(Request $request, $tipe = null) { + // NOTE: + // - `/{tipe}` breaks for values containing "/" because many servers/frameworks decode `%2F` early. + // - Support both route param and query param (?tipe=...) for backward compatibility. + if ($tipe === null) { + $tipe = $request->query('tipe'); + } + $tipe = urldecode((string) $tipe); $tipe = trim($tipe); abort_if($tipe === '', 404); @@ -204,11 +211,11 @@ class PitStopController extends Controller ->where('m.statusenabled', true); }) ->select([ - DB::raw("coalesce(nullif(pl.tipe, ''), '-') as tipe"), + DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-') as tipe"), DB::raw('pl.id as pegawai_id'), DB::raw("count(distinct m.id) as lulus_count"), ]) - ->groupBy(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"), 'pl.id'); + ->groupBy(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"), 'pl.id'); $tipeAgg = DB::connection('pgsql') ->query() @@ -295,15 +302,15 @@ class PitStopController extends Controller $join->on(DB::raw('m.id::text'), '=', 'p.masterpitstop_id') ->where('m.statusenabled', true); }) - ->where(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"), '=', $tipe) + ->where(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"), '=', $tipe) ->select([ 'pl.id', 'pl.nama', 'pl.nik', - DB::raw("coalesce(nullif(pl.tipe, ''), '-') as tipe"), + DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-') as tipe"), DB::raw("count(distinct m.id) filter (where p.status='lulus') as lulus_count"), ]) - ->groupBy('pl.id', 'pl.nama', 'pl.nik', DB::raw("coalesce(nullif(pl.tipe, ''), '-')")) + ->groupBy('pl.id', 'pl.nama', 'pl.nik', DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')")) ->orderBy('pl.nama') ->limit($limit) ->get(); @@ -526,11 +533,11 @@ class PitStopController extends Controller ->where('m.statusenabled', true); }) ->select([ - DB::raw("coalesce(nullif(pl.tipe, ''), '-') as tipe"), + DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-') as tipe"), DB::raw('pl.id as pegawai_id'), DB::raw("count(distinct m.id) as lulus_count"), ]) - ->groupBy(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"), 'pl.id'); + ->groupBy(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"), 'pl.id'); $tipeAgg = DB::connection('pgsql') ->query() @@ -578,7 +585,7 @@ class PitStopController extends Controller $join->on(DB::raw('m.id::text'), '=', 'p.masterpitstop_id') ->where('m.statusenabled', true); }) - ->where(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"), '=', $tipe) + ->where(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"), '=', $tipe) ->select([ 'pl.id', DB::raw("coalesce(pl.nama, '-') as nama"), @@ -1029,11 +1036,11 @@ class PitStopController extends Controller ->where('m.statusenabled', true); }) ->select([ - DB::raw("coalesce(nullif(pl.tipe, ''), '-') as tipe"), + DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-') as tipe"), DB::raw('pl.id as pegawai_id'), DB::raw("count(distinct m.id) as lulus_count"), ]) - ->groupBy(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"), 'pl.id'); + ->groupBy(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"), 'pl.id'); $tipeAgg = DB::connection('pgsql') ->query() @@ -1059,7 +1066,7 @@ class PitStopController extends Controller ->where('m.statusenabled', true); }) ->select([ - DB::raw("coalesce(nullif(pl.tipe, ''), '-') as tipe"), + DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-') as tipe"), 'pl.id', DB::raw("coalesce(pl.nama, '-') as nama"), DB::raw("coalesce(pl.nik, '-') as nik"), @@ -1075,8 +1082,8 @@ class PitStopController extends Controller and px.id is null ), '') as belum_steps"), ]) - ->groupBy(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"), 'pl.id', 'pl.nama', 'pl.nik') - ->orderBy(DB::raw("coalesce(nullif(pl.tipe, ''), '-')")) + ->groupBy(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"), 'pl.id', 'pl.nama', 'pl.nik') + ->orderBy(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')")) ->orderBy('pl.nama') ->get(); @@ -1214,7 +1221,7 @@ class PitStopController extends Controller $join->on(DB::raw('m.id::text'), '=', 'p.masterpitstop_id') ->where('m.statusenabled', true); }) - ->where(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"), '=', $tipe) + ->where(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"), '=', $tipe) ->select([ 'pl.id', DB::raw("coalesce(pl.nama, '-') as nama"), @@ -1431,11 +1438,12 @@ class PitStopController extends Controller ]); } - public function dataProgressExternalByTipe(Request $request, $tipe) + public function dataProgressExternalByTipe(Request $request, $tipe = null) { - $tipe = urldecode((string) $tipe); - $tipe = trim($tipe); - abort_if($tipe === '', 404); + // Support both route param and query param (?tipe=...) so tipe containing "/" works reliably. + if ($tipe === null) { + $tipe = $request->query('tipe'); + } $draw = $this->dtInt($request->input('draw'), 1); $start = $this->dtInt($request->input('start'), 0); @@ -1445,6 +1453,17 @@ class PitStopController extends Controller $search = trim((string) data_get($request->all(), 'search.value', '')); + $tipe = urldecode((string) $tipe); + $tipe = trim($tipe); + if ($tipe === '') { + return response()->json([ + 'draw' => $draw, + 'recordsTotal' => 0, + 'recordsFiltered' => 0, + 'data' => [], + ]); + } + $totalSteps = (int) MasterPitStopPraAkre::where('statusenabled', true)->count(); $baseNoSearch = DB::connection('pgsql') @@ -1457,7 +1476,7 @@ class PitStopController extends Controller $join->on(DB::raw('m.id::text'), '=', 'p.masterpitstop_id') ->where('m.statusenabled', true); }) - ->where(DB::raw("coalesce(nullif(pl.tipe, ''), '-')"), '=', $tipe) + ->where(DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')"), '=', $tipe) ->select([ 'pl.id', DB::raw("coalesce(pl.nama, '-') as nama"), @@ -1600,7 +1619,7 @@ class PitStopController extends Controller 'pl.id', DB::raw("coalesce(pl.nama, '-') as nama"), DB::raw("coalesce(pl.nik, '-') as identitas"), - DB::raw("coalesce(nullif(pl.tipe, ''), '-') as unit_name"), + DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-') as unit_name"), DB::raw("count(distinct m.id) as lulus_count"), DB::raw("coalesce(( select count(*) @@ -1623,7 +1642,7 @@ class PitStopController extends Controller and px.id is null ), '') as belum_steps"), ]) - ->groupBy('pl.id', 'pl.nama', 'pl.nik', DB::raw("coalesce(nullif(pl.tipe, ''), '-')")); + ->groupBy('pl.id', 'pl.nama', 'pl.nik', DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')")); $union = $internal->unionAll($external); @@ -2079,7 +2098,7 @@ class PitStopController extends Controller DB::raw("'luar' as tipe_karyawan"), 'pl.id', DB::raw("coalesce(pl.nama, '-') as nama"), - DB::raw("coalesce(nullif(pl.tipe, ''), '-') as unit_name"), + DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-') as unit_name"), DB::raw("count(distinct m.id) as lulus_count"), DB::raw("coalesce(( select count(*) @@ -2102,7 +2121,7 @@ class PitStopController extends Controller and px.id is null ), '') as belum_steps"), ]) - ->groupBy('pl.id', 'pl.nama', 'pl.nik', DB::raw("coalesce(nullif(pl.tipe, ''), '-')")); + ->groupBy('pl.id', 'pl.nama', 'pl.nik', DB::raw("coalesce(nullif(btrim(pl.tipe), ''), '-')")); $union = $internal->unionAll($external); diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 7aca841..f508d94 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -165,7 +165,7 @@ - + diff --git a/resources/views/pitstop/progress_external_detail.blade.php b/resources/views/pitstop/progress_external_detail.blade.php index a12ec34..369fc33 100644 --- a/resources/views/pitstop/progress_external_detail.blade.php +++ b/resources/views/pitstop/progress_external_detail.blade.php @@ -80,7 +80,7 @@
Nama StepNama Pitstop Nilai Waktu
- + @@ -168,7 +168,8 @@ lengthMenu: [10, 20, 50, 100], order: [[2, 'desc']], ajax: { - url: `/data/progress-external/${encodeURIComponent(tipe)}`, + // Jangan pakai path param: tipe bisa mengandung "/" yang membuat route param rusak. + url: `/data/progress-external/by-tipe?tipe=${encodeURIComponent(tipe)}`, type: 'GET', }, columns: [ diff --git a/resources/views/pitstop/progress_unit.blade.php b/resources/views/pitstop/progress_unit.blade.php index 6e7f821..7203d32 100644 --- a/resources/views/pitstop/progress_unit.blade.php +++ b/resources/views/pitstop/progress_unit.blade.php @@ -161,7 +161,7 @@
Nama StepNama Pitstop Nilai Pemberi Nilai Waktu
- + @@ -347,8 +347,9 @@ orderable: false, searchable: false, render: function (data, type, row) { - const tipe = escapeHtml(row.tipe ?? '-'); - return `Detail`; + // Hindari path param: nilai `tipe` bisa mengandung "/" sehingga route param bisa gagal. + const tipeRaw = String(row.tipe ?? '-'); + return `Detail`; }, }, ], diff --git a/resources/views/pitstop/progress_unit_detail.blade.php b/resources/views/pitstop/progress_unit_detail.blade.php index 13ec68a..7e05bf5 100644 --- a/resources/views/pitstop/progress_unit_detail.blade.php +++ b/resources/views/pitstop/progress_unit_detail.blade.php @@ -80,7 +80,7 @@
Nama StepNama Pitstop Nilai Pemberi Nilai Waktu
- + diff --git a/routes/web.php b/routes/web.php index 507f24e..080da13 100644 --- a/routes/web.php +++ b/routes/web.php @@ -22,9 +22,12 @@ Route::middleware(['auth'])->group(function(){ Route::get('/monitoring-pra-akreditasi/excel-external', [PitStopController::class, 'monitoringExcelExternal']); Route::get('/pitstop/progress-unit/{unit_id}', [PitStopController::class, 'progressUnitDetail']); + // Use query param (?tipe=...) to safely handle values containing "/" (encoded slashes may break route params) + Route::get('/pitstop/progress-external', [PitStopController::class, 'progressExternalDetail']); Route::get('/pitstop/progress-external/{tipe}', [PitStopController::class, 'progressExternalDetail']); Route::get('/data/progress-Internal', [PitStopController::class, 'dataProgress']); Route::get('/data/progress-Internal/{unit_id}', [PitStopController::class, 'dataProgressUnit']); + Route::get('/data/progress-external/by-tipe', [PitStopController::class, 'dataProgressExternalByTipe']); Route::get('/data/progress-external/{tipe}', [PitStopController::class, 'dataProgressExternalByTipe']); Route::get('/data/progress-all-karyawan', [PitStopController::class, 'dataProgressAllKaryawan']);
Nama StepNama Pitstop Nilai Pemberi Nilai Waktu