From c620d7ef8f7e94f5666ce1a97620981d155a99e1 Mon Sep 17 00:00:00 2001 From: Afila Date: Fri, 24 Jun 2022 01:19:40 +0700 Subject: [PATCH 1/3] perbaikan slug untuk prosedur --- .../Informasi/ProsedurController.php | 5 +-- .../Controllers/Page/DownloadController.php | 2 +- app/Models/Prosedur.php | 1 + .../2022_06_22_205014_add_slug_prosedur.php | 36 +++++++++++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 database/migrations/2022_06_22_205014_add_slug_prosedur.php diff --git a/app/Http/Controllers/Informasi/ProsedurController.php b/app/Http/Controllers/Informasi/ProsedurController.php index 34b0453ec..5fd19361d 100644 --- a/app/Http/Controllers/Informasi/ProsedurController.php +++ b/app/Http/Controllers/Informasi/ProsedurController.php @@ -85,7 +85,7 @@ public function store(ProsedurRequest $request) $file_name = time() . rand(100, 999) . '_' . $original_name; $path = "storage/regulasi/"; $file->move($path, $file_name); - + $input['slug'] = str_slug($request->input('judul_prosedur')); $input['file_prosedur'] = $path . $file_name; $input['mime_type'] = $file->getClientOriginalExtension(); } @@ -131,7 +131,8 @@ public function update(Prosedur $prosedur, ProsedurRequest $request) $input['file_prosedur'] = $path . $file_name; $input['mime_type'] = $file->getClientOriginalExtension(); } - + $input['slug'] = str_slug($request->input('judul_prosedur')); + $prosedur->update($input); } catch (\Exception $e) { report($e); diff --git a/app/Http/Controllers/Page/DownloadController.php b/app/Http/Controllers/Page/DownloadController.php index 74070b3da..59af7e7d8 100644 --- a/app/Http/Controllers/Page/DownloadController.php +++ b/app/Http/Controllers/Page/DownloadController.php @@ -66,7 +66,7 @@ public function getDataProsedur() public function showProsedur($nama_prosedur) { - $prosedur = Prosedur::where('judul_prosedur', str_replace('-', ' ', $nama_prosedur))->first(); + $prosedur = Prosedur::where('slug', $nama_prosedur)->first(); $page_title = 'Detail Prosedur :' . $prosedur->judul_prosedur; return view('pages.unduhan.prosedur_show', compact('page_title', 'prosedur')); diff --git a/app/Models/Prosedur.php b/app/Models/Prosedur.php index 2e6740177..8e01184a9 100755 --- a/app/Models/Prosedur.php +++ b/app/Models/Prosedur.php @@ -41,5 +41,6 @@ class Prosedur extends Model 'judul_prosedur', 'file_prosedur', 'mime_type', + 'slug' ]; } diff --git a/database/migrations/2022_06_22_205014_add_slug_prosedur.php b/database/migrations/2022_06_22_205014_add_slug_prosedur.php new file mode 100644 index 000000000..f862bfd1c --- /dev/null +++ b/database/migrations/2022_06_22_205014_add_slug_prosedur.php @@ -0,0 +1,36 @@ +Char('slug', 50)->after('judul_prosedur')->nullable(false); + }); + + // update data slug pada das prosedur + $prosedur = DB::table('das_prosedur')->update(['slug' => DB::raw("replace(judul_prosedur, ' ' , '-')")]); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('das_prosedur', function (Blueprint $table) { + $table->dropColumn('slug'); + }); + } +} From 5a265411f2ced156616c02b9fef99d2e3c7f747c Mon Sep 17 00:00:00 2001 From: apidong Date: Thu, 23 Jun 2022 18:22:36 +0000 Subject: [PATCH 2/3] Fix styling --- .../Informasi/ProsedurController.php | 2 +- .../2022_06_22_205014_add_slug_prosedur.php | 35 +++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Informasi/ProsedurController.php b/app/Http/Controllers/Informasi/ProsedurController.php index 5fd19361d..53b89be16 100644 --- a/app/Http/Controllers/Informasi/ProsedurController.php +++ b/app/Http/Controllers/Informasi/ProsedurController.php @@ -132,7 +132,7 @@ public function update(Prosedur $prosedur, ProsedurRequest $request) $input['mime_type'] = $file->getClientOriginalExtension(); } $input['slug'] = str_slug($request->input('judul_prosedur')); - + $prosedur->update($input); } catch (\Exception $e) { report($e); diff --git a/database/migrations/2022_06_22_205014_add_slug_prosedur.php b/database/migrations/2022_06_22_205014_add_slug_prosedur.php index f862bfd1c..b5faac736 100644 --- a/database/migrations/2022_06_22_205014_add_slug_prosedur.php +++ b/database/migrations/2022_06_22_205014_add_slug_prosedur.php @@ -1,9 +1,38 @@ Char('slug', 50)->after('judul_prosedur')->nullable(false); }); From fc431ea9bfb85e9dd5e6e6fc24f7ff358ce7cc56 Mon Sep 17 00:00:00 2001 From: Agung Sugiarto Date: Sun, 26 Jun 2022 14:33:40 +0700 Subject: [PATCH 3/3] [ci skip] Mutakhirkan catatan rilis --- catatan_rilis.md | 3 +++ database/migrations/2022_06_22_205014_add_slug_prosedur.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/catatan_rilis.md b/catatan_rilis.md index 625da19bb..c5855f61e 100644 --- a/catatan_rilis.md +++ b/catatan_rilis.md @@ -10,8 +10,11 @@ Terima kasih pada [untuk diisi] yang terus berkontribusi. Terima kasih pula pada #### Perbaikan BUG +1. [#430](https://github.com/OpenSID/OpenDK/issues/430) Perbaiki ihat daftar prosedur di menu unduhan error 500. + #### TEKNIS + 1. [#427](https://github.com/OpenSID/OpenDK/pull/427) Teknis perbaiki error 500 setelah login. 2. [#431](https://github.com/OpenSID/OpenDK/pull/431) Teknis ignore .phpcs-cache diff --git a/database/migrations/2022_06_22_205014_add_slug_prosedur.php b/database/migrations/2022_06_22_205014_add_slug_prosedur.php index b5faac736..1590fe1b6 100644 --- a/database/migrations/2022_06_22_205014_add_slug_prosedur.php +++ b/database/migrations/2022_06_22_205014_add_slug_prosedur.php @@ -44,11 +44,11 @@ class AddSlugProsedur extends Migration public function up() { Schema::table('das_prosedur', function (Blueprint $table) { - $table->Char('slug', 50)->after('judul_prosedur')->nullable(false); + $table->char('slug', 50)->after('judul_prosedur')->nullable(false); }); // update data slug pada das prosedur - $prosedur = DB::table('das_prosedur')->update(['slug' => DB::raw("replace(judul_prosedur, ' ' , '-')")]); + DB::table('das_prosedur')->update(['slug' => DB::raw("lower(replace(judul_prosedur, ' ' , '-'))")]); } /**