From f055b22ba8221d8412482829b3cd851603421fb1 Mon Sep 17 00:00:00 2001 From: Ilham Wara Nugroho Date: Tue, 6 Jan 2026 13:45:47 +0700 Subject: [PATCH] update --- .../Setting/DataAktivitasController.php | 32 ++++--- .../Setting/PeraturanController.php | 96 +++++++++++-------- public/storage | 1 + .../file-data-aktivitas/edit.blade.php | 2 +- .../file-data-aktivitas/index.blade.php | 7 +- .../setting/file-peraturan/create.blade.php | 8 +- .../setting/file-peraturan/edit.blade.php | 15 +-- .../setting/file-peraturan/index.blade.php | 73 +++++--------- 8 files changed, 107 insertions(+), 127 deletions(-) create mode 120000 public/storage diff --git a/app/Http/Controllers/Setting/DataAktivitasController.php b/app/Http/Controllers/Setting/DataAktivitasController.php index 21d3be2..c10e5af 100644 --- a/app/Http/Controllers/Setting/DataAktivitasController.php +++ b/app/Http/Controllers/Setting/DataAktivitasController.php @@ -73,16 +73,17 @@ class DataAktivitasController implements HasMiddleware public function edit($id) { - $data = $this->fileService->find($id); - if ($data) { - $data['storagePath'] = 'data_aktivitas/' . $data->sector . '/' . $data->inventory_year; + $datas['data'] = $this->fileService->find($id); + // dd($datas['data']); + if ($datas['data']->file_upload) { + $datas['storagePath'] = 'data_aktivitas/' . $datas['data']->sector . '/' . $datas['data']->inventory_year; } - $data['sectors'] = $this->fileService->getSectors(); - $data['route'] = $this->route; - $data['title'] = $this->title; + $datas['sectors'] = $this->fileService->getSectors(); + $datas['route'] = $this->route; + $datas['title'] = $this->title; - return view($this->template.'.edit', $data); + return view($this->template.'.edit', $datas); } public function update(Request $request, $id) @@ -117,7 +118,7 @@ class DataAktivitasController implements HasMiddleware $storagePath = 'data_aktivitas/' . $data->sector . '/' . $data->inventory_year; } - $this->fileService->destroy($cms, $storagePath); + $this->fileService->destroy($data, $storagePath); return redirect()->route($this->route.'.index')->with('success', 'File Data Aktivitas berhasil dihapus.'); } catch (\Exception $e) { @@ -138,20 +139,23 @@ class DataAktivitasController implements HasMiddleware public function grid(Request $request) { - + // dd($request->all()); $_data = []; $user = Auth::user(); $scope = $user->getScope(); $data = CmsFileDataAktivitas::rowActive(); - + // dd($data->get()); if ($scope === LingkupAksesData::INTERNAL->value) { + dd('a'); $data->whereHas('creator', function ($q) use ($user) { $q->where('agency_id', $user->agency_id); }); } else if ($scope === '') { - $data->where('created_by', null); + // $data->where('created_by', null); } + + // Apply category filter if a category is selected if ($request->has('sectorFilter') && $request->sectorFilter != '' && $request->sectorFilter != 'SEMUA SEKTOR') { $data = $data->where('sector', $request->sectorFilter); @@ -181,9 +185,9 @@ class DataAktivitasController implements HasMiddleware } if ($row->file_upload) { - $storagePath = 'data_aktivitas/' . $row->sector . '/' . $row->inventory_year; - $file = ' - + $storagePath = 'storage/data_aktivitas/' . $row->sector . '/' . $row->inventory_year; + $file = ' + '; } else { $file = 'No File'; diff --git a/app/Http/Controllers/Setting/PeraturanController.php b/app/Http/Controllers/Setting/PeraturanController.php index 88b5ab6..fd932f9 100644 --- a/app/Http/Controllers/Setting/PeraturanController.php +++ b/app/Http/Controllers/Setting/PeraturanController.php @@ -13,6 +13,9 @@ use Yajra\DataTables\DataTables; class PeraturanController implements HasMiddleware { + protected $title = 'Data Pengumuman'; + protected $template = 'modules.setting.file-peraturan'; + protected $route = 'modules.pengaturan.pengumuman'; protected $fileService; public function __construct(PeraturanService $fileService) @@ -29,42 +32,18 @@ class PeraturanController implements HasMiddleware public function index(Request $request) { - if ($request->ajax()) { - $query = $this->fileService->getAll(); + $datas['route'] = $this->route; + $datas['title'] = $this->title; - $result = datatables()->of($query) - ->addColumn('file_upload', function ($row) { - if ($row->file_upload) { - $storagePath = 'peraturan'; - return ' - - '; - } else { - return 'No File'; - } - }) - ->addColumn('action', function ($data) { - $actionBtn = 'Edit'; - $actionBtn .= '
'; - $actionBtn .= csrf_field(); - $actionBtn .= method_field('DELETE'); - $actionBtn .= ''; - $actionBtn .= '
'; - return $actionBtn; - }) - ->rawColumns(['file_upload', 'action']) - ->make(true); - - return $result; - } - - return view('setting.file-peraturan.index'); + return view($this->template.'.index',$datas); } public function create() { - return view('setting.file-peraturan.create'); + $datas['route'] = $this->route; + $datas['title'] = $this->title; + return view($this->template.'.create',$datas); } public function store(Request $request) @@ -79,7 +58,7 @@ class PeraturanController implements HasMiddleware try { $this->fileService->save($request->all()); - return redirect()->route('peraturan.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil diupload.'); + return redirect()->route($this->route.'.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil diupload.'); } catch (\Exception $e) { return back()->withErrors(['error' => 'File Pengumuman / File Peraturan-Peraturan gagal disimpan. Silakan coba lagi. Error: ' . $e->getMessage()]); } @@ -87,12 +66,13 @@ class PeraturanController implements HasMiddleware public function edit($id) { - $data = $this->fileService->find($id); - if ($data) { - $data['storagePath'] = 'peraturan'; + $datas['data'] = $this->fileService->find($id); + if ($datas['data']) { + $datas['storagePath'] = 'peraturan'; } - - return view('setting.file-peraturan.edit', compact('data')); + $datas['route'] = $this->route; + $datas['title'] = $this->title; + return view($this->template.'.edit', $datas); } public function update(Request $request, $id) @@ -110,7 +90,7 @@ class PeraturanController implements HasMiddleware $this->fileService->save($data); - return redirect()->route('peraturan.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil diperbarui.'); + return redirect()->route($this->route.'.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil diperbarui.'); } catch (\Exception $e) { return back()->withErrors(['error' => 'File Pengumuman / File Peraturan-Peraturan gagal diperbarui. Silakan coba lagi. Error: ' . $e->getMessage()]); } @@ -124,11 +104,49 @@ class PeraturanController implements HasMiddleware $storagePath = 'peraturan'; } - $this->fileService->destroy($cms, $storagePath); + $this->fileService->destroy($data, $storagePath); - return redirect()->route('unit.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil dihapus.'); + return redirect()->route($this->route.'.index')->with('success', 'File Pengumuman / File Peraturan-Peraturan berhasil dihapus.'); } catch (\Exception $e) { return back()->withErrors(['error' => 'File Pengumuman / File Peraturan-Peraturan gagal dihapus. Silakan coba lagi. Error: ' . $e->getMessage()]); } } + + public function grid(Request $request) + { + // dd($request->all()); + $_data = []; + $data = $this->fileService->getAll(); + + foreach ($data as $key => $row) { + + $btn = 'Edit'; + $btn .= '
'; + $btn .= csrf_field(); + $btn .= method_field('DELETE'); + $btn .= ''; + $btn .= '
'; + + if ($row->file_upload) { + $storagePath = 'storage/peraturan'; + $file = ' + + '; + } else { + $file = 'No File'; + } + + + $_data[] = [ + 'no' => $key+1, + 'file' => $file, + 'name' => $row->name, + 'description' => $row->description, + 'action' => @$btn, + ]; + + } + + return response()->json($_data); + } } diff --git a/public/storage b/public/storage new file mode 120000 index 0000000..a41b2a5 --- /dev/null +++ b/public/storage @@ -0,0 +1 @@ +/Applications/MAMP/htdocs/sigd_new/storage/app/public \ No newline at end of file diff --git a/resources/views/modules/setting/file-data-aktivitas/edit.blade.php b/resources/views/modules/setting/file-data-aktivitas/edit.blade.php index bc7ca9c..feac46a 100644 --- a/resources/views/modules/setting/file-data-aktivitas/edit.blade.php +++ b/resources/views/modules/setting/file-data-aktivitas/edit.blade.php @@ -99,7 +99,7 @@ id="file_document" name="file_document"> @if ($data->file_upload)
- Download File
@endif diff --git a/resources/views/modules/setting/file-data-aktivitas/index.blade.php b/resources/views/modules/setting/file-data-aktivitas/index.blade.php index 3801e7a..32debb0 100644 --- a/resources/views/modules/setting/file-data-aktivitas/index.blade.php +++ b/resources/views/modules/setting/file-data-aktivitas/index.blade.php @@ -8,12 +8,7 @@
- @if (session('success')) -
- {{ session('success') }} -
- @endif - +
diff --git a/resources/views/modules/setting/file-peraturan/create.blade.php b/resources/views/modules/setting/file-peraturan/create.blade.php index 2dad550..49c031d 100644 --- a/resources/views/modules/setting/file-peraturan/create.blade.php +++ b/resources/views/modules/setting/file-peraturan/create.blade.php @@ -1,11 +1,9 @@ @extends('layouts.master') -@section('title', 'Upload Pengumuman / File Peraturan-Peraturan') - @section('content')
-
Upload Pengumuman / File Peraturan-Peraturan
+
{{ @$title }}
@@ -15,7 +13,7 @@
@endif -
+ @csrf
@@ -54,7 +52,7 @@ {{-- Jenis file yang dibolehkan: pdf, PDF, jpg, JPG, jpeg, JPEG, png, PNG --}}
- Kembali + Kembali
diff --git a/resources/views/modules/setting/file-peraturan/edit.blade.php b/resources/views/modules/setting/file-peraturan/edit.blade.php index 554f3a8..7ea6b0e 100644 --- a/resources/views/modules/setting/file-peraturan/edit.blade.php +++ b/resources/views/modules/setting/file-peraturan/edit.blade.php @@ -1,21 +1,14 @@ @extends('layouts.master') -@section('title', 'Edit Pengumuman / File Peraturan-Peraturan') - @section('content')
-
Edit Pengumuman / File Peraturan-Peraturan
+
{{ @$title }}
- @if ($errors->has('error')) -
- {{ $errors->first('error') }} -
- @endif -
+ @csrf @method('PUT') @@ -47,7 +40,7 @@ id="file_document" name="file_document"> @if ($data->file_upload) @endif @@ -61,7 +54,7 @@
- Kembali + Kembali
diff --git a/resources/views/modules/setting/file-peraturan/index.blade.php b/resources/views/modules/setting/file-peraturan/index.blade.php index 610a6ae..c9730ce 100644 --- a/resources/views/modules/setting/file-peraturan/index.blade.php +++ b/resources/views/modules/setting/file-peraturan/index.blade.php @@ -1,34 +1,38 @@ @extends('layouts.master') -@section('title', 'List Pengumuman / File Peraturan-Peraturan') - @section('content')
-
List Pengumuman / File Peraturan-Peraturan
- Upload +
{{ @$title }}
+ Upload
- @if (session('success')) -
- {{ session('success') }} -
- @endif
- - +
+ - - - - + + + + - - - + +
JudulFileKeteranganAksi#JudulFileKeterangan
@@ -36,37 +40,4 @@ @endsection @section('js') - @endsection