Skip to content

Commit 3465cb5

Browse files
committed
Refactor ArsipController to remove perKro method and update perDetail method for improved search functionality; delete unused view file and update routes accordingly
1 parent aa8bbd7 commit 3465cb5

File tree

3 files changed

+7
-68
lines changed

3 files changed

+7
-68
lines changed

app/Http/Controllers/ArsipController.php

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,20 @@
1010

1111
class ArsipController extends Controller
1212
{
13-
public function perKro($token)
14-
{
15-
$tahun = ShareLink::where('token', $token)->first()->tahun;
16-
$dipa = Dipa::where('tahun', $tahun)->first();
17-
$search = request()->get('search');
18-
19-
$subquery = DB::table('mata_anggarans')
20-
->selectRaw('MID(mak,11,8) as KRO')
21-
->when($search, function ($query, $search) {
22-
return $query->whereRaw('MID(mak,11,8) like ?', ['%'.$search.'%']);
23-
})
24-
->where('dipa_id', ! empty($dipa) ? $dipa->id : null)
25-
->distinct();
26-
27-
$data = DB::table(DB::raw("({$subquery->toSql()}) as sub"))
28-
->mergeBindings($subquery)
29-
->paginate();
30-
31-
return view('arsip-per-kro', [
32-
'level' => 'KRO',
33-
'token' => $token,
34-
'tahun' => $tahun,
35-
'data' => $data,
36-
]);
37-
}
38-
39-
public function perDetail($token, $kro)
13+
public function perDetail($token)
4014
{
4115
$tahun = ShareLink::where('token', $token)->first()->tahun;
4216
$dipa = Dipa::where('tahun', $tahun)->first();
4317
$search = request()->get('search');
4418
$data = DB::table('mata_anggarans')
4519
->select(['mak', 'id', 'uraian'])
4620
->where('dipa_id', ! empty($dipa) ? $dipa->id : null)
47-
->whereLike('mak', '%'.$kro.'%')
4821
->when($search, function ($query, $search) {
49-
return $query->where('mak', 'like', '%'.$search.'%');
22+
$keywords = explode(' ', $search);
23+
foreach ($keywords as $keyword) {
24+
$query->where('mak', 'like', '%'.$keyword.'%');
25+
}
26+
return $query;
5027
})
5128
->orderBy('ordered')->paginate();
5229

resources/views/arsip-per-kro.blade.php

Lines changed: 0 additions & 36 deletions
This file was deleted.

routes/web.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
Route::middleware([ValidateAccessToken::class])
1919
->prefix(Nova::path())
2020
->group(function () {
21-
Route::get('/arsip-dokumen/{token}', [ArsipController::class, 'perKro'])
22-
->name('arsip-per-kro');
23-
Route::get('/arsip-dokumen/{token}/kro/{kro}', [ArsipController::class, 'perDetail'])
21+
Route::get('/arsip-dokumen/{token}', [ArsipController::class, 'perDetail'])
2422
->name('arsip-per-detail');
2523
Route::get('/arsip-dokumen/{token}/coa/{coa}', [ArsipController::class, 'perKak'])
2624
->name('arsip-per-kak');

0 commit comments

Comments
 (0)