From 7e840ab3a4fafbcd0d286a070a05c04d769b1284 Mon Sep 17 00:00:00 2001 From: Ahmad Afandi Date: Tue, 18 Nov 2025 10:36:18 +0700 Subject: [PATCH 1/3] perbaikan jumlah desa --- app/Models/Desa.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Models/Desa.php b/app/Models/Desa.php index 17f48146..d1350eb5 100644 --- a/app/Models/Desa.php +++ b/app/Models/Desa.php @@ -124,7 +124,7 @@ public function scopeDesaBaru($query) ->selectRaw('(CASE WHEN (versi_hosting IS NULL) THEN versi_lokal WHEN (versi_lokal IS NULL) THEN versi_hosting WHEN (tgl_rekam_hosting > tgl_rekam_lokal) THEN versi_hosting ELSE versi_lokal END) as versi') ->where('created_at', '>=', now()->subDay(7)) // filter ip lokal - ->whereRaw("(CASE WHEN ((url_hosting = '' || url_hosting IS NULL) && (url_lokal Like 'localhost%' || url_lokal Like '10.%' || url_lokal Like '127.%' || url_lokal Like '192.168.%' || url_lokal Like '169.254.%' || url_lokal REGEXP '(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)')) THEN 0 ELSE 1 END) = 1") // 0 = i local + //->whereRaw("(CASE WHEN ((url_hosting = '' || url_hosting IS NULL) && (url_lokal Like 'localhost%' || url_lokal Like '10.%' || url_lokal Like '127.%' || url_lokal Like '192.168.%' || url_lokal Like '169.254.%' || url_lokal REGEXP '(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)')) THEN 0 ELSE 1 END) = 1") // 0 = i local ->when(session('provinsi'), function ($query, $provinsi) { $query->where('kode_provinsi', $provinsi->kode_prov); }); @@ -136,15 +136,16 @@ public function scopeSemuaDesa($query) ->select(['*']) ->selectRaw('(CASE WHEN (versi_hosting IS NULL) THEN versi_lokal WHEN (versi_lokal IS NULL) THEN versi_hosting WHEN (tgl_rekam_hosting > tgl_rekam_lokal) THEN versi_hosting ELSE versi_lokal END) as versi') // filter ip lokal - ->whereRaw("(CASE WHEN ((url_hosting = '' || url_hosting IS NULL) && (url_lokal Like 'localhost%' || url_lokal Like '10.%' || url_lokal Like '127.%' || url_lokal Like '192.168.%' || url_lokal Like '169.254.%' || url_lokal REGEXP '(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)')) THEN 0 ELSE 1 END) = 1") // 0 = i local + //->whereRaw("(CASE WHEN ((url_hosting = '' || url_hosting IS NULL) && (url_lokal Like 'localhost%' || url_lokal Like '10.%' || url_lokal Like '127.%' || url_lokal Like '192.168.%' || url_lokal Like '169.254.%' || url_lokal REGEXP '(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)')) THEN 0 ELSE 1 END) = 1") // 0 = i local ->when(session('provinsi'), function ($query, $provinsi) { $query->where('kode_provinsi', $provinsi->kode_prov); }); } public function scopeDesaValid($query) - { - return $query->whereRaw("(CASE WHEN ((url_hosting = '' || url_hosting IS NULL) && (url_lokal Like 'localhost%' || url_lokal Like '10.%' || url_lokal Like '127.%' || url_lokal Like '192.168.%' || url_lokal Like '169.254.%' || url_lokal REGEXP '(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)')) THEN 0 ELSE 1 END) = 1"); // 0 = i local; + { + return $query; + // return $query->whereRaw("(CASE WHEN ((url_hosting = '' || url_hosting IS NULL) && (url_lokal Like 'localhost%' || url_lokal Like '10.%' || url_lokal Like '127.%' || url_lokal Like '192.168.%' || url_lokal Like '169.254.%' || url_lokal REGEXP '(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)')) THEN 0 ELSE 1 END) = 1"); // 0 = i local; } From a36e0a57b6afbc543d1d7bf01b91562db3240d7f Mon Sep 17 00:00:00 2001 From: Ahmad Afandi Date: Tue, 18 Nov 2025 11:09:55 +0700 Subject: [PATCH 2/3] buat migrasi untuk membersihkan data --- app/Models/Desa.php | 4 +-- ...25_11_18_110243_set_kode_desa_not_null.php | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2025_11_18_110243_set_kode_desa_not_null.php diff --git a/app/Models/Desa.php b/app/Models/Desa.php index d1350eb5..3ae7c978 100644 --- a/app/Models/Desa.php +++ b/app/Models/Desa.php @@ -144,8 +144,8 @@ public function scopeSemuaDesa($query) public function scopeDesaValid($query) { - return $query; - // return $query->whereRaw("(CASE WHEN ((url_hosting = '' || url_hosting IS NULL) && (url_lokal Like 'localhost%' || url_lokal Like '10.%' || url_lokal Like '127.%' || url_lokal Like '192.168.%' || url_lokal Like '169.254.%' || url_lokal REGEXP '(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)')) THEN 0 ELSE 1 END) = 1"); // 0 = i local; + return $query->whereRaw('1 = 1'); + //return $query->whereRaw("(CASE WHEN ((url_hosting = '' || url_hosting IS NULL) && (url_lokal Like 'localhost%' || url_lokal Like '10.%' || url_lokal Like '127.%' || url_lokal Like '192.168.%' || url_lokal Like '169.254.%' || url_lokal REGEXP '(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)')) THEN 0 ELSE 1 END) = 1"); // 0 = i local; } diff --git a/database/migrations/2025_11_18_110243_set_kode_desa_not_null.php b/database/migrations/2025_11_18_110243_set_kode_desa_not_null.php new file mode 100644 index 00000000..90fcd07e --- /dev/null +++ b/database/migrations/2025_11_18_110243_set_kode_desa_not_null.php @@ -0,0 +1,30 @@ +delete(); + Schema::table('desa', function(Blueprint $table){ + $table->string('kode_desa')->nullable(false)->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('desa', function(Blueprint $table){ + $table->string('kode_desa')->nullable(false)->change(); + }); + } +}; From 72d46d8559bc65694297b42f5b005d16a2effd15 Mon Sep 17 00:00:00 2001 From: Ahmad Afandi Date: Tue, 18 Nov 2025 12:25:54 +0700 Subject: [PATCH 3/3] update migrasi --- .../migrations/2025_11_18_110243_set_kode_desa_not_null.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/migrations/2025_11_18_110243_set_kode_desa_not_null.php b/database/migrations/2025_11_18_110243_set_kode_desa_not_null.php index 90fcd07e..d8fa0005 100644 --- a/database/migrations/2025_11_18_110243_set_kode_desa_not_null.php +++ b/database/migrations/2025_11_18_110243_set_kode_desa_not_null.php @@ -14,7 +14,7 @@ public function up(): void { Desa::whereNull('kode_desa')->delete(); Schema::table('desa', function(Blueprint $table){ - $table->string('kode_desa')->nullable(false)->change(); + $table->string('kode_desa')->nullable(false)->change(); }); } @@ -24,7 +24,7 @@ public function up(): void public function down(): void { Schema::table('desa', function(Blueprint $table){ - $table->string('kode_desa')->nullable(false)->change(); + $table->string('kode_desa')->nullable(true)->change(); }); } };