diff --git a/app/Http/Controllers/Dashboard/DatatableController.php b/app/Http/Controllers/Dashboard/DatatableController.php index d9af561..daad262 100644 --- a/app/Http/Controllers/Dashboard/DatatableController.php +++ b/app/Http/Controllers/Dashboard/DatatableController.php @@ -402,10 +402,20 @@ public function governmentAgency(Request $request){ if ($request->ajax()) { $data = GovernmentAgency::with(['issues'])->get(); + $newData = $request->input('new_data', null); + return DataTables::of($data) ->addIndexColumn() + ->addColumn('name', function ($data) use ($newData) { + + if(filled($newData) && decrypt_id($newData) == $data->id){ + return 'Baru'. $data->name; + }else{ + return $data->name; + } + }) ->addColumn('short_name', function ($data) { - return filled($data->short_name) ? $data->short_name : '-'; + return filled($data->short_name) ? $data->short_name : 'Belum ditambahkan'; }) ->addColumn('issues', function ($data) { $issueCount = $data->issues->count(); @@ -446,7 +456,7 @@ public function governmentAgency(Request $request){ return $dropdown; }) - ->rawColumns(['issues', 'action']) + ->rawColumns(['name', 'short_name', 'issues', 'action']) ->make(true); } diff --git a/app/Http/Controllers/Dashboard/GovernmentAgencyController.php b/app/Http/Controllers/Dashboard/GovernmentAgencyController.php index ca942df..2afbc37 100644 --- a/app/Http/Controllers/Dashboard/GovernmentAgencyController.php +++ b/app/Http/Controllers/Dashboard/GovernmentAgencyController.php @@ -13,13 +13,14 @@ class GovernmentAgencyController extends Controller { public function index(){ return view('dashboard.government-agencies.index', [ - 'title' => 'OPD' + 'title' => 'Data OPD', + 'new_data' => session()->get('new_data', null), ]); } public function create(){ return view('dashboard.government-agencies.create', [ - 'title' => 'Tambah OPD' + 'title' => 'Buat OPD Baru' ]); } @@ -27,11 +28,12 @@ public function store(GovernmentAgencyRequest $request){ $validatedData = $request->validated(); $validatedData['enhancer_id'] = Auth::id(); - $createdGovernmentAgency = GovernmentAgency::create($validatedData); + try{ + $createdGovernmentAgency = GovernmentAgency::create($validatedData); - if($createdGovernmentAgency){ - return redirect()->route('dashboard.government.agencies.index')->with('success-status', 'Berhasil menambahkan OPD.'); - }else{ + return redirect()->route('dashboard.government.agencies.index')->with('success-status', 'Berhasil membuat OPD baru.') + ->with('new_data', encrypt_id($createdGovernmentAgency->id)); + }catch(\Exception $e){ return redirect()->back()->with('failed-status', 'Gagal menambahkan OPD'); } } @@ -53,7 +55,7 @@ public function update(GovernmentAgencyRequest $request, $id){ $updatedGovernmentAgency = $governmentAgency->update($validatedData); if($updatedGovernmentAgency){ - return redirect()->back()->with('success-status', 'Berhasil mengubah OPD.'); + return redirect()->route('dashboard.government.agencies.show', ['id' => encrypt_id($governmentAgency->id)])->with('success-status', 'Berhasil mengubah OPD.'); }else{ return redirect()->back()->with('failed-status', 'Gagal mengubah OPD'); } diff --git a/app/Models/GovernmentAgency.php b/app/Models/GovernmentAgency.php index 1890727..94f1ee3 100644 --- a/app/Models/GovernmentAgency.php +++ b/app/Models/GovernmentAgency.php @@ -25,4 +25,8 @@ public function issues() ->using(IssueManagementGovernmentAgency::class) ->withTimestamps(); } + + public function enhancer(){ + return $this->belongsTo(User::class, 'enhancer_id', 'id'); + } } diff --git a/resources/views/dashboard/government-agencies/create.blade.php b/resources/views/dashboard/government-agencies/create.blade.php index 6b48cc1..3d81e5b 100644 --- a/resources/views/dashboard/government-agencies/create.blade.php +++ b/resources/views/dashboard/government-agencies/create.blade.php @@ -10,7 +10,10 @@
-
{{$title}}
+
+
Buat OPD Baru
+

Masukkan informasi yang diperlukan untuk membuat OPD.

+
@csrf @@ -19,7 +22,7 @@
- +
@error('name') {{$message}} @@ -30,18 +33,18 @@
- +
@error('short_name') {{$message}} @enderror
-
+
- +
@error('location') {{$message}} @@ -55,6 +58,9 @@
+ @error('description') + {{$message}} + @enderror

diff --git a/resources/views/dashboard/government-agencies/edit.blade.php b/resources/views/dashboard/government-agencies/edit.blade.php index 24f2d6e..4b38b4f 100644 --- a/resources/views/dashboard/government-agencies/edit.blade.php +++ b/resources/views/dashboard/government-agencies/edit.blade.php @@ -10,7 +10,10 @@
-
{{$title}}
+
+
Ubah OPD
+

Perbarui informasi OPD ini.

+
@csrf @@ -20,7 +23,7 @@
- +
@error('name') {{$message}} @@ -31,18 +34,18 @@
- +
@error('short_name') {{$message}} @enderror
-
+
- +
@error('location') {{$message}} @@ -56,6 +59,9 @@
+ @error('description') + {{$message}} + @enderror

diff --git a/resources/views/dashboard/government-agencies/show.blade.php b/resources/views/dashboard/government-agencies/show.blade.php index 0e29a98..c3022c1 100644 --- a/resources/views/dashboard/government-agencies/show.blade.php +++ b/resources/views/dashboard/government-agencies/show.blade.php @@ -6,13 +6,32 @@
+
+
+
+

Detail OPD

+
+
    +
  • Detail OPD dapat dilihat di sini.
  • +
+
+
+
+ + Kembali +
+
+
@@ -58,6 +77,12 @@ {{idn_date($governmentAgency->created_at, 'l, d F Y')}}
+
+
+ Dibuat Oleh + {{$governmentAgency->enhancer->name ?? '-'}} +
+
{{--
--}} @@ -73,11 +98,6 @@
-
-
- Kembali - Ubah -
diff --git a/resources/views/dashboard/sub-locations/index.blade.php b/resources/views/dashboard/sub-locations/index.blade.php index 41e13c1..d91b918 100644 --- a/resources/views/dashboard/sub-locations/index.blade.php +++ b/resources/views/dashboard/sub-locations/index.blade.php @@ -47,7 +47,7 @@ No Nama Lokus - Isu + Jumlah Isu Status diff --git a/resources/views/partials/app/datatable.blade.php b/resources/views/partials/app/datatable.blade.php index c8a50d4..2429237 100644 --- a/resources/views/partials/app/datatable.blade.php +++ b/resources/views/partials/app/datatable.blade.php @@ -250,7 +250,13 @@ $('#governmentAgenciesTable').DataTable({ processing: true, serverSide: true, - ajax: '{{ route('dashboard.government.agencies.data') }}', + ajax: { + url: '{{ route('dashboard.government.agencies.data') }}', + type: 'GET', + data: function(d) { + d.new_data = '{{ $new_data }}'; + } + }, columns: [ { data: 'DT_RowIndex', name: 'DT_RowIndex', orderable: false, searchable: false }, { data: 'name', name: 'name' }, @@ -261,16 +267,18 @@ { data: 'id', name: 'id', orderable: true, searchable: false, visible: false }, ], columnDefs: [ - { targets: 0, width: 'auto' }, - { targets: 2, width: '10%' }, - { targets: 3, width: '7%' }, + { targets: 0, width: '2%' }, // Index + { targets: 1, width: '20%' }, // Name + { targets: 2, width: '6%' }, // Short Name + { targets: 3, width: '3%' }, // Issue + { targets: 4, width: '2%', className: 'text-center' }, // Action button + { - targets: [1], - createdCell: function(td, cellData, rowData, row, col) { + targets: [1, 2], // Title & Link + createdCell: function(td) { $(td).css({ - 'word-wrap': 'break-word', 'white-space': 'normal', - 'overflow-wrap': 'break-word' + 'word-break': 'break-word', }); } } @@ -278,7 +286,7 @@ language: datatableLanguage, // responsive: true, autoWidth: false, - order: [[4, 'desc']], + order: [[5, 'desc']], pagingType: "simple", lengthMenu: [[10, 25, 50, 100, -1], ['Tampilkan 10 data', 'Tampilkan 25 data', 'Tampilkan 50 data', 'Tampilkan 100 data', 'Tampilkan semua']], scrollX: true