From 9b9a1c3f4c29e81c6d319338bb04f092f56eef37 Mon Sep 17 00:00:00 2001 From: Afila Date: Fri, 11 Oct 2024 06:00:00 +0700 Subject: [PATCH] Ubah permision pada file logging (#444) Co-authored-by: sarwono Co-authored-by: scqolbu24 --- .../Commands/BackupDatabaseStorage.php | 2 + app/Console/Commands/BackupGoogleDrive.php | 1 + app/Console/Commands/BackupVps.php | 1 + app/Console/Commands/BpsKemendagriCommand.php | 2 + app/Console/Commands/DesaOptimasiCommand.php | 2 + app/Exports/DesaExport.php | 6 +- app/Exports/KelolaDesaExport.php | 8 +- app/Exports/LayananDesaExport.php | 8 +- app/Exports/OpenDKExport.php | 16 +-- app/Exports/WilayahDesaExport.php | 4 +- app/Exports/WilayahKabupatenExport.php | 4 +- app/Exports/WilayahKecamatanExport.php | 4 +- app/Exports/WilayahProvinsiExport.php | 4 +- app/Helpers/helper.php | 80 +++++++----- .../PengaturanAplikasiController.php | 6 +- .../Admin/Wilayah/DesaController.php | 16 +-- .../Admin/Wilayah/KabupatenController.php | 30 ++--- .../Admin/Wilayah/KecamatanController.php | 18 +-- .../Admin/Wilayah/ProvinsiController.php | 18 +-- .../Api/InstallOpenDKController.php | 23 ++-- .../Api/InstallOpensidController.php | 22 ++-- app/Http/Controllers/Api/TrackController.php | 14 +-- .../Api/TrackOpenkabController.php | 9 +- .../Controllers/Api/TrackPBBController.php | 2 +- app/Http/Controllers/DashboardController.php | 114 ++++++++++-------- .../KelolaDesaDashboardController.php | 70 +++++------ app/Http/Controllers/LaporanController.php | 33 ++--- .../LaporanDesaAktifController.php | 8 +- .../Controllers/LaporanTemaController.php | 13 +- .../LayananDesaDashboardController.php | 70 +++++------ app/Http/Controllers/MobileController.php | 34 +++--- .../Controllers/OpenDKDashboardController.php | 62 +++++----- app/Http/Controllers/OpendkController.php | 18 +-- app/Http/Controllers/OpenkabController.php | 10 +- app/Http/Controllers/PbbController.php | 15 ++- .../WebsiteDashboardController.php | 59 +++++---- app/Http/Middleware/WebDashboard.php | 15 +-- app/Http/Requests/TrackKelolaDesaRequest.php | 2 +- app/Http/Requests/TrackMobileRequest.php | 2 +- app/Http/Requests/TrackPBBRequest.php | 4 +- app/Http/Requests/TrackRequest.php | 8 +- app/Models/Desa.php | 15 ++- app/Models/Opendk.php | 4 +- app/Models/Openkab.php | 15 ++- app/Models/Pbb.php | 4 +- app/Models/TrackKeloladesa.php | 6 +- app/Models/TrackMobile.php | 8 +- .../CustomTelegramServiceProvider.php | 3 +- catatan_rilis.md | 7 +- 49 files changed, 478 insertions(+), 421 deletions(-) diff --git a/app/Console/Commands/BackupDatabaseStorage.php b/app/Console/Commands/BackupDatabaseStorage.php index 486221db..5c154fd5 100644 --- a/app/Console/Commands/BackupDatabaseStorage.php +++ b/app/Console/Commands/BackupDatabaseStorage.php @@ -52,6 +52,8 @@ public function handle() $this->folder_database = folderBackupDatabase(); $this->backupDatabase(); $this->backupStorage(); + + changeLogPermissions('777'); } } diff --git a/app/Console/Commands/BackupGoogleDrive.php b/app/Console/Commands/BackupGoogleDrive.php index ca68e1a3..96ef6f7e 100644 --- a/app/Console/Commands/BackupGoogleDrive.php +++ b/app/Console/Commands/BackupGoogleDrive.php @@ -56,6 +56,7 @@ public function handle() // proses backup $this->remote->backupToCloudStorage($storage_type, $remote_name, tanggal_backup(), null); + changeLogPermissions('777'); } } } diff --git a/app/Console/Commands/BackupVps.php b/app/Console/Commands/BackupVps.php index 73bc4304..aa9546e1 100644 --- a/app/Console/Commands/BackupVps.php +++ b/app/Console/Commands/BackupVps.php @@ -59,6 +59,7 @@ public function handle() // proses backup $this->remote->backupToCloudStorage($storage_type, $remote_name, tanggal_backup(), $root); + changeLogPermissions('777'); } } } diff --git a/app/Console/Commands/BpsKemendagriCommand.php b/app/Console/Commands/BpsKemendagriCommand.php index bfb02273..03ac3205 100644 --- a/app/Console/Commands/BpsKemendagriCommand.php +++ b/app/Console/Commands/BpsKemendagriCommand.php @@ -81,8 +81,10 @@ public function handle() $this->requests($this->provinsi, 'kabupaten'); $this->requests($this->kabupaten, 'kecamatan'); $this->requests($this->kecamatan, 'desa'); + changeLogPermissions('777'); } catch (ClientException $e) { report($e); + changeLogPermissions('777'); } } diff --git a/app/Console/Commands/DesaOptimasiCommand.php b/app/Console/Commands/DesaOptimasiCommand.php index 9eb24fa8..36f834f5 100644 --- a/app/Console/Commands/DesaOptimasiCommand.php +++ b/app/Console/Commands/DesaOptimasiCommand.php @@ -65,5 +65,7 @@ public function handle() ]); } }); + + changeLogPermissions('777'); } } diff --git a/app/Exports/DesaExport.php b/app/Exports/DesaExport.php index c4f75d37..2ef2732a 100644 --- a/app/Exports/DesaExport.php +++ b/app/Exports/DesaExport.php @@ -3,8 +3,8 @@ namespace App\Exports; use Maatwebsite\Excel\Concerns\FromCollection; -use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\ShouldAutoSize; +use Maatwebsite\Excel\Concerns\WithHeadings; class DesaExport implements FromCollection, WithHeadings, ShouldAutoSize { @@ -17,14 +17,14 @@ public function __construct($data) public function collection() { - return $this->data->map(function($item, $index) { + return $this->data->map(function ($item, $index) { return [ 'no' => $index + 1, // Menambahkan nomor urut berdasarkan index 'nama_desa' => $item->nama_desa, 'nama_kecamatan' => $item->nama_kecamatan, 'nama_kabupaten' => $item->nama_kabupaten, 'nama_provinsi' => $item->nama_provinsi, - 'kontak' => ($item->kontak['nama'] ?? '') . ' ' . ($item->kontak['hp'] ?? ''), + 'kontak' => ($item->kontak['nama'] ?? '').' '.($item->kontak['hp'] ?? ''), 'url_hosting' => $item->url_hosting, 'versi_lokal' => $item->versi_lokal, 'versi_hosting' => $item->versi_hosting, diff --git a/app/Exports/KelolaDesaExport.php b/app/Exports/KelolaDesaExport.php index 061a5f78..dad78e39 100644 --- a/app/Exports/KelolaDesaExport.php +++ b/app/Exports/KelolaDesaExport.php @@ -3,8 +3,8 @@ namespace App\Exports; use Maatwebsite\Excel\Concerns\FromCollection; -use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\ShouldAutoSize; +use Maatwebsite\Excel\Concerns\WithHeadings; class KelolaDesaExport implements FromCollection, WithHeadings, ShouldAutoSize { @@ -17,7 +17,7 @@ public function __construct($data) public function collection() { - return $this->data->map(function($item, $index) { + return $this->data->map(function ($item, $index) { return [ 'no' => $index + 1, // Menambahkan nomor urut berdasarkan index 'id_device' => $item->id_device, @@ -39,7 +39,7 @@ public function headings(): array 'Desa', 'Kecamatan', 'Kabupaten', - 'Provinsi' + 'Provinsi', ]; } -} \ No newline at end of file +} diff --git a/app/Exports/LayananDesaExport.php b/app/Exports/LayananDesaExport.php index cbfb77e2..ca9f481b 100644 --- a/app/Exports/LayananDesaExport.php +++ b/app/Exports/LayananDesaExport.php @@ -3,8 +3,8 @@ namespace App\Exports; use Maatwebsite\Excel\Concerns\FromCollection; -use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\ShouldAutoSize; +use Maatwebsite\Excel\Concerns\WithHeadings; class LayananDesaExport implements FromCollection, WithHeadings, ShouldAutoSize { @@ -17,7 +17,7 @@ public function __construct($data) public function collection() { - return $this->data->map(function($item, $index) { + return $this->data->map(function ($item, $index) { return [ 'no' => $index + 1, // Menambahkan nomor urut berdasarkan index 'id' => $item->id, @@ -39,7 +39,7 @@ public function headings(): array 'Desa', 'Kecamatan', 'Kabupaten', - 'Provinsi' + 'Provinsi', ]; } -} \ No newline at end of file +} diff --git a/app/Exports/OpenDKExport.php b/app/Exports/OpenDKExport.php index 7b466c0d..00c70c3b 100644 --- a/app/Exports/OpenDKExport.php +++ b/app/Exports/OpenDKExport.php @@ -3,8 +3,8 @@ namespace App\Exports; use Maatwebsite\Excel\Concerns\FromCollection; -use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\ShouldAutoSize; +use Maatwebsite\Excel\Concerns\WithHeadings; class OpenDKExport implements FromCollection, WithHeadings, ShouldAutoSize { @@ -17,7 +17,7 @@ public function __construct($data) public function collection() { - return $this->data->map(function($item, $index) { + return $this->data->map(function ($item, $index) { return [ 'no' => $index + 1, // Menambahkan nomor urut berdasarkan index 'nama_kecamatan' => $item->nama_kecamatan, @@ -26,10 +26,10 @@ public function collection() 'url' => $item->url, 'versi' => $item->versi, 'format_updated_at' => $item->format_updated_at, - 'Batas Wilayah Utara' => ($item->batas_wilayah == null)? '' : $item->batas_wilayah['bts_wil_utara'] ?? '', - 'Batas Wilayah Barat' => ($item->batas_wilayah == null)? '' : $item->batas_wilayah['bts_wil_barat'] ?? '', - 'Batas Wilayah Timur' => ($item->batas_wilayah == null)? '' : $item->batas_wilayah['bts_wil_timur'] ?? '', - 'Batas Wilayah Selatan' => ($item->batas_wilayah == null)? '' : $item->batas_wilayah['bts_wil_selatan'] ?? '', + 'Batas Wilayah Utara' => ($item->batas_wilayah == null) ? '' : $item->batas_wilayah['bts_wil_utara'] ?? '', + 'Batas Wilayah Barat' => ($item->batas_wilayah == null) ? '' : $item->batas_wilayah['bts_wil_barat'] ?? '', + 'Batas Wilayah Timur' => ($item->batas_wilayah == null) ? '' : $item->batas_wilayah['bts_wil_timur'] ?? '', + 'Batas Wilayah Selatan' => ($item->batas_wilayah == null) ? '' : $item->batas_wilayah['bts_wil_selatan'] ?? '', 'Jumlah Desa' => $item->jml_desa, 'Jumlah Desa Tersinkronisasi' => $item->jumlahdesa_sinkronisasi, 'Jumlah Penduduk' => $item->jumlah_penduduk, @@ -59,7 +59,7 @@ public function headings(): array 'Jumlah Penduduk', 'Jumlah KK', 'Jumlah Program Bantuan', - 'Alamat Kantor' + 'Alamat Kantor', ]; } -} \ No newline at end of file +} diff --git a/app/Exports/WilayahDesaExport.php b/app/Exports/WilayahDesaExport.php index e30a390e..2ed6a1eb 100644 --- a/app/Exports/WilayahDesaExport.php +++ b/app/Exports/WilayahDesaExport.php @@ -3,8 +3,8 @@ namespace App\Exports; use Maatwebsite\Excel\Concerns\FromCollection; -use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\ShouldAutoSize; +use Maatwebsite\Excel\Concerns\WithHeadings; class WilayahDesaExport implements FromCollection, WithHeadings, ShouldAutoSize { @@ -17,7 +17,7 @@ public function __construct($data) public function collection() { - return $this->data->map(function($item, $index) { + return $this->data->map(function ($item, $index) { return [ 'no' => $index + 1, // Menambahkan nomor urut berdasarkan index 'kode_desa' => $item->kode_desa, diff --git a/app/Exports/WilayahKabupatenExport.php b/app/Exports/WilayahKabupatenExport.php index c940e00d..1f33ee43 100644 --- a/app/Exports/WilayahKabupatenExport.php +++ b/app/Exports/WilayahKabupatenExport.php @@ -3,8 +3,8 @@ namespace App\Exports; use Maatwebsite\Excel\Concerns\FromCollection; -use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\ShouldAutoSize; +use Maatwebsite\Excel\Concerns\WithHeadings; class WilayahKabupatenExport implements FromCollection, WithHeadings, ShouldAutoSize { @@ -17,7 +17,7 @@ public function __construct($data) public function collection() { - return $this->data->map(function($item, $index) { + return $this->data->map(function ($item, $index) { return [ 'no' => $index + 1, // Menambahkan nomor urut berdasarkan index 'kode_kabupaten' => $item->kode_kabupaten, diff --git a/app/Exports/WilayahKecamatanExport.php b/app/Exports/WilayahKecamatanExport.php index 5af7dcda..d7b75b60 100644 --- a/app/Exports/WilayahKecamatanExport.php +++ b/app/Exports/WilayahKecamatanExport.php @@ -3,8 +3,8 @@ namespace App\Exports; use Maatwebsite\Excel\Concerns\FromCollection; -use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\ShouldAutoSize; +use Maatwebsite\Excel\Concerns\WithHeadings; class WilayahKecamatanExport implements FromCollection, WithHeadings, ShouldAutoSize { @@ -17,7 +17,7 @@ public function __construct($data) public function collection() { - return $this->data->map(function($item, $index) { + return $this->data->map(function ($item, $index) { return [ 'no' => $index + 1, // Menambahkan nomor urut berdasarkan index 'kode_kecamatan' => $item->kode_kecamatan, diff --git a/app/Exports/WilayahProvinsiExport.php b/app/Exports/WilayahProvinsiExport.php index de52f2eb..a443c205 100644 --- a/app/Exports/WilayahProvinsiExport.php +++ b/app/Exports/WilayahProvinsiExport.php @@ -3,8 +3,8 @@ namespace App\Exports; use Maatwebsite\Excel\Concerns\FromCollection; -use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\ShouldAutoSize; +use Maatwebsite\Excel\Concerns\WithHeadings; class WilayahProvinsiExport implements FromCollection, WithHeadings, ShouldAutoSize { @@ -17,7 +17,7 @@ public function __construct($data) public function collection() { - return $this->data->map(function($item, $index) { + return $this->data->map(function ($item, $index) { return [ 'no' => $index + 1, // Menambahkan nomor urut berdasarkan index 'kode_provinsi' => $item->kode_provinsi, diff --git a/app/Helpers/helper.php b/app/Helpers/helper.php index c1e28c15..ed437ae5 100644 --- a/app/Helpers/helper.php +++ b/app/Helpers/helper.php @@ -1,9 +1,9 @@ 'application/vnd.github.v3+json', ]) - ->get($url) - ->throw(); + ->get($url) + ->throw(); return json_decode($response->body()); } catch (Throwable $th) { @@ -167,19 +167,17 @@ function lastrelease_opensid() */ function lastrelease_pbb() { - // Cache data until the end of the day - $version = Cache::remember('release_pbb', now()->endOfDay(), function () { + $version = Cache::remember('release_pbb', now()->endOfDay(), function () { $version = '2401.0.0'; $versi_pbb = lastrelease('https://api.github.com/repos/OpenSID/rilis-pbb/releases/latest'); if ($versi_pbb !== false) { - $version = str_replace('v', '', $versi_pbb->tag_name); + $version = str_replace('v', '', $versi_pbb->tag_name); } return $version; }); - return $version; } @@ -207,7 +205,7 @@ function pantau_wilayah_khusus() */ function abaikan_domain($aplikasi) { - switch($aplikasi) { + switch ($aplikasi) { case 'opendk': return Cache::get('abaikan_domain_opendk', ''); break; @@ -245,16 +243,16 @@ function cleanVersi($version) function lastrelease_opendk() { // Cache data until the end of the day - $version = Cache::remember('release_opendk', now()->endOfDay(), function () { + $version = Cache::remember('release_opendk', now()->endOfDay(), function () { $version = '2404.0.0'; $versi_api = lastrelease('https://api.github.com/repos/OpenSID/opendk/releases/latest'); if ($versi_api !== false) { - $version = str_replace('v', '', $versi_api->tag_name); + $version = str_replace('v', '', $versi_api->tag_name); } return $version; - }); + }); return $version; } @@ -343,36 +341,36 @@ function formatDateTimeForHuman($datetime) { $now = Carbon::now(); $formattedDateTime = Carbon::parse($datetime); - + // Calculate differences $diff = $formattedDateTime->diff($now); - + // Determine the appropriate format based on the difference if ($formattedDateTime->isFuture()) { if ($diff->y > 0) { - return $diff->y . ' tahun ' . $diff->m . ' bulan ' . $diff->d . ' hari lagi'; + return $diff->y.' tahun '.$diff->m.' bulan '.$diff->d.' hari lagi'; } elseif ($diff->m > 0) { - return $diff->m . ' bulan ' . $diff->d . ' hari lagi'; + return $diff->m.' bulan '.$diff->d.' hari lagi'; } elseif ($diff->d > 0) { - return $diff->d . ' hari lagi'; + return $diff->d.' hari lagi'; } elseif ($diff->h > 0) { - return $diff->h . ' jam ' . $diff->i . ' menit lagi'; + return $diff->h.' jam '.$diff->i.' menit lagi'; } elseif ($diff->i > 0) { - return $diff->i . ' menit ' . $diff->s . ' detik lagi'; + return $diff->i.' menit '.$diff->s.' detik lagi'; } else { return 'baru saja'; } } else { if ($diff->y > 0) { - return $diff->y . ' tahun lalu'; + return $diff->y.' tahun lalu'; } elseif ($diff->m > 0) { - return $diff->m . ' bulan lalu'; + return $diff->m.' bulan lalu'; } elseif ($diff->d > 0) { - return $diff->d . ' hari lalu'; + return $diff->d.' hari lalu'; } elseif ($diff->h > 0) { - return $diff->h . ' jam lalu'; + return $diff->h.' jam lalu'; } elseif ($diff->i > 0) { - return $diff->i . ' menit ' . $diff->s . ' detik lalu'; + return $diff->i.' menit '.$diff->s.' detik lalu'; } else { return 'baru saja'; } @@ -382,28 +380,25 @@ function formatDateTimeForHuman($datetime) } if (! function_exists('lastrelease_api_layanandesa')) { - function lastrelease_api_layanandesa() { - // Cache data until the end of the day - $version = Cache::remember('release_layanan_desa', now()->endOfDay(), function () { + $version = Cache::remember('release_layanan_desa', now()->endOfDay(), function () { $version = '2404.0.0'; $versi_api = lastrelease('https://api.github.com/repos/OpenSID/rilis-opensid-api/releases/latest'); if ($versi_api !== false) { - $version = str_replace('v', '', $versi_api->tag_name); + $version = str_replace('v', '', $versi_api->tag_name); } return $version; }); - return $version; } } -if (! function_exists('format_angka')) { +if (! function_exists('format_angka')) { function format_angka($angka, $decimals = 0) { return number_format($angka, $decimals, ',', '.'); @@ -411,9 +406,30 @@ function format_angka($angka, $decimals = 0) } if (! function_exists('local_date')) { - function local_date($date, $format = 'l, j F Y H:i:s'){ + function local_date($date, $format = 'l, j F Y H:i:s') + { $date = Carbon::parse($date)->locale('id'); $date->settings(['formatFunction' => 'translatedFormat']); - return $date->format($format); + + return $date->format($format); } -} \ No newline at end of file +} + +if (! function_exists('changeLogPermissions')) { + function changeLogPermissions($permissions = '777') + { + // Path ke folder logs + $logPath = storage_path('logs'); + + // Periksa apakah folder ada + if (is_dir($logPath)) { + // Ubah izin sesuai parameter + exec("chmod -R $permissions $logPath", $output, $returnVar); + + // Cek hasil perintah + return $returnVar === 0; + } + + return false; + } +} diff --git a/app/Http/Controllers/Admin/Pengaturan/PengaturanAplikasiController.php b/app/Http/Controllers/Admin/Pengaturan/PengaturanAplikasiController.php index 4c2f85e0..ab9d0384 100644 --- a/app/Http/Controllers/Admin/Pengaturan/PengaturanAplikasiController.php +++ b/app/Http/Controllers/Admin/Pengaturan/PengaturanAplikasiController.php @@ -33,12 +33,12 @@ public function store(PengaturanAplikasiRequest $request) foreach ($request->all() as $key => $value) { if (is_array($value)) { switch ($key) { - case 'id_telegram': - case 'abaikan_domain_opendk': + case 'id_telegram': + case 'abaikan_domain_opendk': case 'abaikan_domain_opensid': $value = $value ? implode('|', $value) : null; break; - default: + default: $value = collect($value)->map(function ($item) { return json_decode($item); })->toJson(); diff --git a/app/Http/Controllers/Admin/Wilayah/DesaController.php b/app/Http/Controllers/Admin/Wilayah/DesaController.php index e8db09fe..56836ddc 100644 --- a/app/Http/Controllers/Admin/Wilayah/DesaController.php +++ b/app/Http/Controllers/Admin/Wilayah/DesaController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Admin\Wilayah; +use App\Exports\WilayahDesaExport; use App\Http\Controllers\Controller; use App\Http\Requests\RegionRequest; use App\Imports\RegionImport; @@ -10,23 +11,24 @@ use Illuminate\Support\Facades\Storage; use Maatwebsite\Excel\Facades\Excel; use Yajra\DataTables\DataTables; -use App\Exports\WilayahDesaExport; class DesaController extends Controller { public function index(Request $request) { - if($request->excel){ - $paramDatatable = json_decode($request->get('params'), 1); - $request->merge($paramDatatable); + if ($request->excel) { + $paramDatatable = json_decode($request->get('params'), 1); + $request->merge($paramDatatable); } - if ($request->ajax() || $request->excel) { + if ($request->ajax() || $request->excel) { $query = DataTables::of(Region::desa()); - if($request->excel){ + if ($request->excel) { $query->filtering(); - return Excel::download(new WilayahDesaExport($query->results()), 'Wilayah-Desa.xlsx');; + + return Excel::download(new WilayahDesaExport($query->results()), 'Wilayah-Desa.xlsx'); } + return $query->addIndexColumn() ->addColumn('action', function ($data) { $edit = ''; diff --git a/app/Http/Controllers/Admin/Wilayah/KabupatenController.php b/app/Http/Controllers/Admin/Wilayah/KabupatenController.php index 5e482fe3..a99708ab 100644 --- a/app/Http/Controllers/Admin/Wilayah/KabupatenController.php +++ b/app/Http/Controllers/Admin/Wilayah/KabupatenController.php @@ -2,12 +2,12 @@ namespace App\Http\Controllers\Admin\Wilayah; +use App\Exports\WilayahKabupatenExport; use App\Http\Controllers\Controller; use App\Models\Region; use Illuminate\Http\Request; -use Yajra\DataTables\DataTables; use Maatwebsite\Excel\Facades\Excel; -use App\Exports\WilayahKabupatenExport; +use Yajra\DataTables\DataTables; class KabupatenController extends Controller { @@ -18,19 +18,21 @@ public function index() public function datatables(Request $request) { - if($request->excel){ - $paramDatatable = json_decode($request->get('params'), 1); - $request->merge($paramDatatable); - } - - if ($request->ajax() || $request->excel) { - $query = DataTables::of(Region::kabupaten()); - if($request->excel){ - $query->filtering(); - return Excel::download(new WilayahKabupatenExport($query->results()), 'Wilayah-Kabupaten.xlsx');; + if ($request->excel) { + $paramDatatable = json_decode($request->get('params'), 1); + $request->merge($paramDatatable); } - return $query->addIndexColumn() - ->make(true); + + if ($request->ajax() || $request->excel) { + $query = DataTables::of(Region::kabupaten()); + if ($request->excel) { + $query->filtering(); + + return Excel::download(new WilayahKabupatenExport($query->results()), 'Wilayah-Kabupaten.xlsx'); + } + + return $query->addIndexColumn() + ->make(true); } abort(404); diff --git a/app/Http/Controllers/Admin/Wilayah/KecamatanController.php b/app/Http/Controllers/Admin/Wilayah/KecamatanController.php index db71fcc5..982ad484 100644 --- a/app/Http/Controllers/Admin/Wilayah/KecamatanController.php +++ b/app/Http/Controllers/Admin/Wilayah/KecamatanController.php @@ -2,13 +2,13 @@ namespace App\Http\Controllers\Admin\Wilayah; +use App\Exports\WilayahKecamatanExport; use App\Http\Controllers\Controller; use App\Http\Requests\RegionKecamatanRequest; use App\Models\Region; use Illuminate\Http\Request; -use Yajra\DataTables\DataTables; use Maatwebsite\Excel\Facades\Excel; -use App\Exports\WilayahKecamatanExport; +use Yajra\DataTables\DataTables; class KecamatanController extends Controller { @@ -16,17 +16,19 @@ public function index(Request $request) { $r = Region::with(['child'])->find(67); - if($request->excel){ - $paramDatatable = json_decode($request->get('params'), 1); - $request->merge($paramDatatable); + if ($request->excel) { + $paramDatatable = json_decode($request->get('params'), 1); + $request->merge($paramDatatable); } - if ($request->ajax() || $request->excel) { + if ($request->ajax() || $request->excel) { $query = DataTables::of(Region::kecamatan()); - if($request->excel){ + if ($request->excel) { $query->filtering(); - return Excel::download(new WilayahKecamatanExport($query->results()), 'Wilayah-Kecamatan.xlsx');; + + return Excel::download(new WilayahKecamatanExport($query->results()), 'Wilayah-Kecamatan.xlsx'); } + return $query->addIndexColumn() ->addColumn('action', function ($data) { $edit = ''; diff --git a/app/Http/Controllers/Admin/Wilayah/ProvinsiController.php b/app/Http/Controllers/Admin/Wilayah/ProvinsiController.php index a87f8afa..73310463 100644 --- a/app/Http/Controllers/Admin/Wilayah/ProvinsiController.php +++ b/app/Http/Controllers/Admin/Wilayah/ProvinsiController.php @@ -2,12 +2,12 @@ namespace App\Http\Controllers\Admin\Wilayah; +use App\Exports\WilayahProvinsiExport; use App\Http\Controllers\Controller; use App\Models\Region; use Illuminate\Http\Request; -use Yajra\DataTables\DataTables; use Maatwebsite\Excel\Facades\Excel; -use App\Exports\WilayahProvinsiExport; +use Yajra\DataTables\DataTables; class ProvinsiController extends Controller { @@ -18,17 +18,19 @@ public function index() public function datatables(Request $request) { - if($request->excel){ - $paramDatatable = json_decode($request->get('params'), 1); - $request->merge($paramDatatable); + if ($request->excel) { + $paramDatatable = json_decode($request->get('params'), 1); + $request->merge($paramDatatable); } - if ($request->ajax() || $request->excel) { + if ($request->ajax() || $request->excel) { $query = DataTables::of(Region::provinsi()); - if($request->excel){ + if ($request->excel) { $query->filtering(); - return Excel::download(new WilayahProvinsiExport($query->results()), 'Wilayah-Provinsi.xlsx');; + + return Excel::download(new WilayahProvinsiExport($query->results()), 'Wilayah-Provinsi.xlsx'); } + return $query->addIndexColumn() ->make(true); } diff --git a/app/Http/Controllers/Api/InstallOpenDKController.php b/app/Http/Controllers/Api/InstallOpenDKController.php index c267f5ba..a8184b7d 100644 --- a/app/Http/Controllers/Api/InstallOpenDKController.php +++ b/app/Http/Controllers/Api/InstallOpenDKController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; -use App\Models\Desa; use App\Models\Opendk; use Carbon\Carbon; use Illuminate\Http\Request; @@ -11,7 +10,7 @@ class InstallOpenDKController extends Controller { public function chart(Request $request) - { + { $provinsi = $request->get('provinsi'); $kabupaten = $request->get('kabupaten'); $kecamatan = $request->get('kecamatan'); @@ -19,25 +18,25 @@ public function chart(Request $request) $opendk = Opendk::selectRaw("DATE_FORMAT(created_at, '%m-%Y') month_year, count(*) as total") ->groupBy('month_year')->orderBy('created_at')->whereDate('created_at', '>', $minCreatedAt); if ($provinsi) { - $opendk->where('kode_provinsi', $provinsi); + $opendk->where('kode_provinsi', $provinsi); } if ($kabupaten) { - $opendk->where('kode_kabupaten', $kabupaten); + $opendk->where('kode_kabupaten', $kabupaten); } if ($kecamatan) { - $opendk->where('kode_kecamatan', $kecamatan); + $opendk->where('kode_kecamatan', $kecamatan); } - + $opendkData = $opendk->get(); $labels = []; - $datasetOpendk = []; - foreach ($opendkData as $item) { - $period = Carbon::createFromFormat('d-m-Y', '01-'.$item->month_year)->translatedFormat('M-y'); + $datasetOpendk = []; + foreach ($opendkData as $item) { + $period = Carbon::createFromFormat('d-m-Y', '01-'.$item->month_year)->translatedFormat('M-y'); $labels[] = $period; $datasetOpendk[] = $item->total; - } - $datasets = [ - ['label' => 'OpenDK', 'data' => $datasetOpendk], + } + $datasets = [ + ['label' => 'OpenDK', 'data' => $datasetOpendk], ]; $result = [ diff --git a/app/Http/Controllers/Api/InstallOpensidController.php b/app/Http/Controllers/Api/InstallOpensidController.php index 128df18a..fc127c55 100644 --- a/app/Http/Controllers/Api/InstallOpensidController.php +++ b/app/Http/Controllers/Api/InstallOpensidController.php @@ -10,7 +10,7 @@ class InstallOpensidController extends Controller { public function chart(Request $request) - { + { $provinsi = $request->get('provinsi'); $kabupaten = $request->get('kabupaten'); $kecamatan = $request->get('kecamatan'); @@ -18,25 +18,25 @@ public function chart(Request $request) $opensid = Desa::selectRaw("DATE_FORMAT(created_at, '%m-%Y') month_year, count(*) as total") ->groupBy('month_year')->orderBy('created_at')->whereDate('created_at', '>', $minCreatedAt); if ($provinsi) { - $opensid->where('kode_provinsi', $provinsi); + $opensid->where('kode_provinsi', $provinsi); } if ($kabupaten) { - $opensid->where('kode_kabupaten', $kabupaten); + $opensid->where('kode_kabupaten', $kabupaten); } if ($kecamatan) { - $opensid->where('kode_kecamatan', $kecamatan); + $opensid->where('kode_kecamatan', $kecamatan); } - + $opensidData = $opensid->get(); $labels = []; - $datasetOpensid = []; - foreach ($opensidData as $item) { - $period = Carbon::createFromFormat('d-m-Y', '01-'.$item->month_year)->translatedFormat('M-y'); + $datasetOpensid = []; + foreach ($opensidData as $item) { + $period = Carbon::createFromFormat('d-m-Y', '01-'.$item->month_year)->translatedFormat('M-y'); $labels[] = $period; $datasetOpensid[] = $item->total; - } - $datasets = [ - ['label' => 'OpenSID', 'data' => $datasetOpensid], + } + $datasets = [ + ['label' => 'OpenSID', 'data' => $datasetOpensid], ]; $result = [ diff --git a/app/Http/Controllers/Api/TrackController.php b/app/Http/Controllers/Api/TrackController.php index 4fa097b2..2e353ac9 100644 --- a/app/Http/Controllers/Api/TrackController.php +++ b/app/Http/Controllers/Api/TrackController.php @@ -34,31 +34,31 @@ public function __invoke(TrackRequest $request) } else { Akses::create( $request->merge(['desa_id' => $desa->id])->only(['desa_id', 'url_referrer', 'request_uri', 'client_ip', 'external_ip', 'opensid_version', 'tgl']) - ); + ); } $notifikasi = Notifikasi::semuaNotifDesa($desa->id); NotifikasiDesa::nonAktifkan(collect($notifikasi), $desa->id); DB::commit(); - if($desa->isPemdaHosting() && $desa->isNew()){ + if ($desa->isPemdaHosting() && $desa->isNew()) { $userIdTelegram = Cache::get('id_telegram'); $tokenBotTelegram = Cache::get('token_bot_telegram'); - if($tokenBotTelegram && $userIdTelegram){ + if ($tokenBotTelegram && $userIdTelegram) { $message = <<kode_desa} Nama desa/kec/kabupaten/provinsi : {$desa->nama_desa}/{$desa->nama_kecamatan}/{$desa->nama_kabupaten}/{$desa->nama_provinsi} Tanggal/waktu terpantau : {$desa->created_at} Domain dan IP Address : {$desa->url_hosting} / {$desa->ip_hosting} -STR; - +STR; + foreach ($userIdTelegram as $key => $id) { Notification::route('telegram', 'Pantau Notifikasi')->notify(new InfoNotification($id, $message)); } - } + } } - + return response()->json($notifikasi); } catch (\Exception $e) { Log::error($e); diff --git a/app/Http/Controllers/Api/TrackOpenkabController.php b/app/Http/Controllers/Api/TrackOpenkabController.php index 8f9c4ad1..d77504bd 100644 --- a/app/Http/Controllers/Api/TrackOpenkabController.php +++ b/app/Http/Controllers/Api/TrackOpenkabController.php @@ -2,12 +2,11 @@ namespace App\Http\Controllers\Api; -use Exception; -use App\Models\Openkab; -use Illuminate\Support\Facades\Log; use App\Http\Controllers\Controller; -use Illuminate\Support\Facades\Request; use App\Http\Requests\TrackOpenkabRequest; +use App\Models\Openkab; +use Exception; +use Illuminate\Support\Facades\Log; class TrackOpenkabController extends Controller { @@ -23,7 +22,7 @@ public function __invoke(TrackOpenkabRequest $request) } catch (Exception $e) { Log::error($e); - return response()->json('Failed', 422); + return response()->json('Failed', 422); } } } diff --git a/app/Http/Controllers/Api/TrackPBBController.php b/app/Http/Controllers/Api/TrackPBBController.php index 1400a184..eab12618 100644 --- a/app/Http/Controllers/Api/TrackPBBController.php +++ b/app/Http/Controllers/Api/TrackPBBController.php @@ -13,7 +13,7 @@ class TrackPBBController extends Controller public function __invoke(TrackPBBRequest $request) { try { - Pbb::upsert($request->requestData(),['kode_desa']); + Pbb::upsert($request->requestData(), ['kode_desa']); return response()->json(['status' => true]); } catch (Exception $e) { diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index a473f46c..f7043358 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -2,8 +2,6 @@ namespace App\Http\Controllers; -use App\Http\Requests\TrackPBBRequest; -use App\Models\Akses; use App\Models\Desa; use App\Models\Opendk; use App\Models\Openkab; @@ -74,15 +72,17 @@ public function datatableOpendkBaru(Request $request) $desa = Opendk::select('nama_kecamatan as region', 'created_at as tanggal')->orderBY('created_at', 'desc')->limit(7)->get() ->map(function ($item) { $item->tanggal = formatDateTimeForHuman($item->tanggal); // Misalnya formatDateTimeForHuman merupakan fungsi untuk mengubah format tanggal - $item->tanggal = '' . $item->tanggal . ''; // Menambahkan kelas Bootstrap + $item->tanggal = ''.$item->tanggal.''; // Menambahkan kelas Bootstrap + return $item; }); + return DataTables::of($desa) ->addIndexColumn() // Menambahkan kolom indeks - ->escapeColumns([]) + ->escapeColumns([]) ->make(true); } - + abort(404); // Mengembalikan 404 jika bukan permintaan AJAX } @@ -92,15 +92,17 @@ public function datatableOpenkabBaru(Request $request) $desa = Openkab::select('nama_kab as region', 'created_at as tanggal')->orderBY('created_at', 'desc')->limit(7)->get() ->map(function ($item) { $item->tanggal = formatDateTimeForHuman($item->tanggal); // Misalnya formatDateTimeForHuman merupakan fungsi untuk mengubah format tanggal - $item->tanggal = '' . $item->tanggal . ''; // Menambahkan kelas Bootstrap + $item->tanggal = ''.$item->tanggal.''; // Menambahkan kelas Bootstrap + return $item; }); + return DataTables::of($desa) ->addIndexColumn() // Menambahkan kolom indeks - ->escapeColumns([]) + ->escapeColumns([]) ->make(true); } - + abort(404); // Mengembalikan 404 jika bukan permintaan AJAX } @@ -110,15 +112,17 @@ public function datatableOpensidBaru(Request $request) $desa = Desa::select('nama_desa as region', 'created_at as tanggal')->orderBY('created_at', 'desc')->limit(7)->get() ->map(function ($item) { $item->tanggal = formatDateTimeForHuman($item->tanggal); // Misalnya formatDateTimeForHuman merupakan fungsi untuk mengubah format tanggal - $item->tanggal = '' . $item->tanggal . ''; // Menambahkan kelas Bootstrap + $item->tanggal = ''.$item->tanggal.''; // Menambahkan kelas Bootstrap + return $item; }); + return DataTables::of($desa) ->addIndexColumn() // Menambahkan kolom indeks - ->escapeColumns([]) + ->escapeColumns([]) ->make(true); } - + abort(404); // Mengembalikan 404 jika bukan permintaan AJAX } @@ -132,15 +136,17 @@ public function datatableLayanandesaBaru(Request $request) ->get() ->map(function ($item) { $item->tanggal = formatDateTimeForHuman($item->tanggal); // Misalnya formatDateTimeForHuman merupakan fungsi untuk mengubah format tanggal - $item->tanggal = '' . $item->tanggal . ''; // Menambahkan kelas Bootstrap + $item->tanggal = ''.$item->tanggal.''; // Menambahkan kelas Bootstrap + return $item; }); + return DataTables::of($desa) ->addIndexColumn() // Menambahkan kolom indeks - ->escapeColumns([]) + ->escapeColumns([]) ->make(true); } - + abort(404); // Mengembalikan 404 jika bukan permintaan AJAX } @@ -154,15 +160,17 @@ public function datatableKeloladesaBaru(Request $request) ->get() ->map(function ($item) { $item->tanggal = formatDateTimeForHuman($item->tanggal); // Misalnya formatDateTimeForHuman merupakan fungsi untuk mengubah format tanggal - $item->tanggal = '' . $item->tanggal . ''; // Menambahkan kelas Bootstrap + $item->tanggal = ''.$item->tanggal.''; // Menambahkan kelas Bootstrap + return $item; }); + return DataTables::of($desa) ->addIndexColumn() // Menambahkan kolom indeks - ->escapeColumns([]) + ->escapeColumns([]) ->make(true); } - + abort(404); // Mengembalikan 404 jika bukan permintaan AJAX } @@ -172,15 +180,17 @@ public function datatablePbbBaru(Request $request) $desa = Pbb::select('nama_desa as region', 'created_at as tanggal')->orderBY('created_at', 'desc')->limit(7)->get() ->map(function ($item) { $item->tanggal = formatDateTimeForHuman($item->tanggal); // Misalnya formatDateTimeForHuman merupakan fungsi untuk mengubah format tanggal - $item->tanggal = '' . $item->tanggal . ''; // Menambahkan kelas Bootstrap + $item->tanggal = ''.$item->tanggal.''; // Menambahkan kelas Bootstrap + return $item; }); + return DataTables::of($desa) ->addIndexColumn() // Menambahkan kolom indeks - ->escapeColumns([]) + ->escapeColumns([]) ->make(true); } - + abort(404); // Mengembalikan 404 jika bukan permintaan AJAX } @@ -192,52 +202,58 @@ public function datatablePenggunaLayanandesa(Request $request) ->get() ->map(function ($item) { $item->tanggal = formatDateTimeForHuman($item->created_at); // Misalnya formatDateTimeForHuman merupakan fungsi untuk mengubah format tanggal - $item->tanggal = '' . $item->tanggal . ''; // Menambahkan kelas Bootstrap + $item->tanggal = ''.$item->tanggal.''; // Menambahkan kelas Bootstrap + return $item; }); + return DataTables::of($desa) ->addIndexColumn() // Menambahkan kolom indeks - ->escapeColumns([]) + ->escapeColumns([]) ->make(true); } abort(404); // Mengembalikan 404 jika bukan permintaan AJAX } - + public function datatablePenggunaOpendk(Request $request) { if ($request->ajax()) { $desa = Opendk::orderBY('created_at', 'desc')->get() ->map(function ($item) { $item->tanggal = formatDateTimeForHuman($item->created_at); // Misalnya formatDateTimeForHuman merupakan fungsi untuk mengubah format tanggal - $item->tanggal = '' . $item->tanggal . ''; // Menambahkan kelas Bootstrap + $item->tanggal = ''.$item->tanggal.''; // Menambahkan kelas Bootstrap + return $item; }); + return DataTables::of($desa) - ->editColumn('updated_at', static fn($q) => $q->updated_at->format('Y-m-d H:i:s')) + ->editColumn('updated_at', static fn ($q) => $q->updated_at->format('Y-m-d H:i:s')) ->addIndexColumn() // Menambahkan kolom indeks - ->escapeColumns([]) + ->escapeColumns([]) ->make(true); } - + abort(404); // Mengembalikan 404 jika bukan permintaan AJAX } - + public function datatablePenggunaPbb(Request $request) { if ($request->ajax()) { $desa = Pbb::orderBY('created_at', 'desc')->get() ->map(function ($item) { $item->tanggal = formatDateTimeForHuman($item->created_at); // Misalnya formatDateTimeForHuman merupakan fungsi untuk mengubah format tanggal - $item->tanggal = '' . $item->tanggal . ''; // Menambahkan kelas Bootstrap + $item->tanggal = ''.$item->tanggal.''; // Menambahkan kelas Bootstrap + return $item; }); + return DataTables::of($desa) ->addIndexColumn() // Menambahkan kolom indeks - ->escapeColumns([]) + ->escapeColumns([]) ->make(true); } - + abort(404); // Mengembalikan 404 jika bukan permintaan AJAX } @@ -249,12 +265,14 @@ public function datatablePenggunaKeloladesa(Request $request) ->get() ->map(function ($item) { $item->tanggal = formatDateTimeForHuman($item->created_at); // Misalnya formatDateTimeForHuman merupakan fungsi untuk mengubah format tanggal - $item->tanggal = '' . $item->tanggal . ''; // Menambahkan kelas Bootstrap + $item->tanggal = ''.$item->tanggal.''; // Menambahkan kelas Bootstrap + return $item; }); + return DataTables::of($desa) ->addIndexColumn() // Menambahkan kolom indeks - ->escapeColumns([]) + ->escapeColumns([]) ->make(true); } @@ -265,49 +283,51 @@ public function dataPeta() { $markers = Desa::select(['lat', 'lng', 'alamat_kantor as popup'])->get()->map(function ($marker) { $marker->color = 'default'; + return $marker; }); - + // Mengembalikan data sebagai response JSON return response()->json($markers); } - + public function datatablePenggunaOpenkab(Request $request) { if ($request->ajax()) { $desa = Openkab::orderBY('created_at', 'desc')->get() ->map(function ($item) { $item->tanggal = formatDateTimeForHuman($item->created_at); // Misalnya formatDateTimeForHuman merupakan fungsi untuk mengubah format tanggal - $item->tanggal = '' . $item->tanggal . ''; // Menambahkan kelas Bootstrap + $item->tanggal = ''.$item->tanggal.''; // Menambahkan kelas Bootstrap + return $item; }); + return DataTables::of($desa) ->addIndexColumn() // Menambahkan kolom indeks - ->escapeColumns([]) + ->escapeColumns([]) ->make(true); } abort(404); // Mengembalikan 404 jika bukan permintaan AJAX } - + public function datatablePenggunaOpensid(Request $request) { - if ($request->ajax()) { + if ($request->ajax()) { return DataTables::of(Desa::orderBy('created_at', 'desc')) - ->editColumn('modul_tte', function($item){ - if($item->modul_tte == 0){ + ->editColumn('modul_tte', function ($item) { + if ($item->modul_tte == 0) { return 'Tidak Aktif'; - }elseif($item->modul_tte == 1){ + } elseif ($item->modul_tte == 1) { return 'Aktif'; } - })->editColumn('tanggal', static fn($item) => '' . formatDateTimeForHuman($item->created_at) . '') + })->editColumn('tanggal', static fn ($item) => ''.formatDateTimeForHuman($item->created_at).'') ->addIndexColumn() // Menambahkan kolom indeks - ->escapeColumns() - ->rawColumns(['modul_tte', 'tanggal']) + ->escapeColumns() + ->rawColumns(['modul_tte', 'tanggal']) ->make(true); } - + abort(404); // Mengembalikan 404 jika bukan permintaan AJAX } - } diff --git a/app/Http/Controllers/KelolaDesaDashboardController.php b/app/Http/Controllers/KelolaDesaDashboardController.php index 140ccf9d..bb874ede 100644 --- a/app/Http/Controllers/KelolaDesaDashboardController.php +++ b/app/Http/Controllers/KelolaDesaDashboardController.php @@ -18,7 +18,8 @@ public function index(Request $request) 'kode_kecamatan' => $request->kode_kecamatan, ]; $versiTerakhir = lastrelease_api_layanandesa(); - $installHariIni = TrackKeloladesa::with(['desa'])->whereDate('created_at', '>=',Carbon::now()->startOfYear()->format('Y-m-d'))->get(); + $installHariIni = TrackKeloladesa::with(['desa'])->whereDate('created_at', '>=', Carbon::now()->startOfYear()->format('Y-m-d'))->get(); + return view('website.keloladesa.index', [ 'fillters' => $fillters, 'total_versi' => 2, @@ -28,7 +29,7 @@ public function index(Request $request) 'info_rilis' => 'Rilis KelolaDesa '.$versiTerakhir, 'total_versi' => TrackKeloladesa::distinct('versi')->count(), 'pengguna_versi_terakhir' => TrackKeloladesa::where('versi', $versiTerakhir)->count(), - 'installHariIni' => $installHariIni + 'installHariIni' => $installHariIni, ]); } @@ -38,7 +39,7 @@ public function detail() } public function versi(Request $request) - { + { $fillters = [ 'kode_provinsi' => $request->kode_provinsi, 'kode_kabupaten' => $request->kode_kabupaten, @@ -46,7 +47,7 @@ public function versi(Request $request) ]; if ($request->ajax()) { - return DataTables::of(TrackKeloladesa::groupBy('versi')->selectRaw('versi, count(*) as jumlah')) + return DataTables::of(TrackKeloladesa::groupBy('versi')->selectRaw('versi, count(*) as jumlah')) ->addIndexColumn() ->make(true); } @@ -55,16 +56,17 @@ public function versi(Request $request) } public function versi_detail(Request $request) - { + { $fillters = [ 'kode_provinsi' => $request->kode_provinsi, 'kode_kabupaten' => $request->kode_kabupaten, 'kode_kecamatan' => $request->kode_kecamatan, ]; - + if ($request->ajax()) { $versi = $request->versi; - return DataTables::of(TrackKeloladesa::filter($fillters)->when($versi, static fn($q) => $q->where('versi', $versi))->with(['desa'])->groupBy(['versi', 'kode_desa'])->selectRaw('kode_desa, versi, count(*) as jumlah')) + + return DataTables::of(TrackKeloladesa::filter($fillters)->when($versi, static fn ($q) => $q->where('versi', $versi))->with(['desa'])->groupBy(['versi', 'kode_desa'])->selectRaw('kode_desa, versi, count(*) as jumlah')) ->addIndexColumn() ->make(true); } @@ -73,14 +75,14 @@ public function versi_detail(Request $request) } public function install_baru(Request $request) - { + { if ($request->ajax()) { return DataTables::of(TrackKeloladesa::with('desa')->whereDate('created_at', '>=', Carbon::now()->subDays(7))) - ->editColumn('updated_at', static fn($q) => $q->updated_at->translatedFormat('j F Y H:i')) + ->editColumn('updated_at', static fn ($q) => $q->updated_at->translatedFormat('j F Y H:i')) ->addIndexColumn() ->make(true); - } - } + } + } public function summary(Request $request) { @@ -88,16 +90,16 @@ public function summary(Request $request) $provinsi = $request->get('provinsi'); $kabupaten = $request->get('kabupaten'); $kecamatan = $request->get('kecamatan'); - $summary = Desa::selectRaw('count(distinct kode_desa) as desa, count(distinct kode_kecamatan) as kecamatan, count(distinct kode_kabupaten) as kabupaten, count(distinct kode_provinsi) as provinsi')->whereIn('kode_desa', function($q){ + $summary = Desa::selectRaw('count(distinct kode_desa) as desa, count(distinct kode_kecamatan) as kecamatan, count(distinct kode_kabupaten) as kabupaten, count(distinct kode_provinsi) as provinsi')->whereIn('kode_desa', function ($q) { return $q->selectRaw('distinct kode_desa')->from('track_keloladesa'); }); - $summarySebelumnya = Desa::selectRaw('count(distinct kode_desa) as desa, count(distinct kode_kecamatan) as kecamatan, count(distinct kode_kabupaten) as kabupaten, count(distinct kode_provinsi) as provinsi')->whereIn('kode_desa', function($q){ + $summarySebelumnya = Desa::selectRaw('count(distinct kode_desa) as desa, count(distinct kode_kecamatan) as kecamatan, count(distinct kode_kabupaten) as kabupaten, count(distinct kode_provinsi) as provinsi')->whereIn('kode_desa', function ($q) { return $q->selectRaw('distinct kode_desa')->from('track_keloladesa'); }); $tanggalAkhir = explode(' - ', $period)[1]; $summary->where('created_at', '<=', $tanggalAkhir); - $summarySebelumnya->where('created_at', '<=', Carbon::parse($tanggalAkhir)->subMonth()->format('Y-m-d')); + $summarySebelumnya->where('created_at', '<=', Carbon::parse($tanggalAkhir)->subMonth()->format('Y-m-d')); if ($provinsi) { $summary->where('kode_provinsi', $provinsi); @@ -120,8 +122,8 @@ public function summary(Request $request) 'kabupaten' => ['total' => $summareResult->kabupaten, 'pertumbuhan' => $summareResult->kabupaten - $summarySebelumnyaResult->kabupaten], 'kecamatan' => ['total' => $summareResult->kecamatan, 'pertumbuhan' => $summareResult->kecamatan - $summarySebelumnyaResult->kecamatan], 'desa' => ['total' => $summareResult->desa, 'pertumbuhan' => $summareResult->desa - $summarySebelumnyaResult->desa], - ], - ] + ], + ] ); } @@ -131,46 +133,46 @@ public function peta(Request $request) $fillters = [ 'kode_provinsi' => $request->kode_provinsi, 'kode_kabupaten' => $request->kode_kabupaten, - 'kode_kecamatan' => $request->kode_kecamatan, + 'kode_kecamatan' => $request->kode_kecamatan, 'status' => null, 'akses' => null, 'versi_lokal' => null, 'versi_hosting' => null, - 'tte' => null, + 'tte' => null, ]; $geoJSONdata = Desa::fillter($fillters) ->whereRaw("CONCAT('',lat * 1) = lat") // tdk ikut sertakan data bukan bilangan ->whereRaw("CONCAT('',lng * 1) = lng") // tdk ikut sertakan data bukan bilangan ->whereRaw('lat BETWEEN -10 AND 6') - ->whereRaw('lng BETWEEN 95 AND 142') + ->whereRaw('lng BETWEEN 95 AND 142') ->where(function ($query) { $query ->where('lat', '!=', config('tracksid.desa_contoh.lat')) ->where('lng', '!=', config('tracksid.desa_contoh.lng')); - }) - ->whereIn('kode_desa', function($q){ + }) + ->whereIn('kode_desa', function ($q) { return $q->selectRaw('distinct kode_desa')->from('track_keloladesa'); })->orderBy('kode_desa', 'ASC')->get()->map(function ($desa) { - return [ - 'type' => 'Feature', - 'geometry' => [ - 'type' => 'Point', - 'coordinates' => [ - (float) $desa->lng, - (float) $desa->lat, + return [ + 'type' => 'Feature', + 'geometry' => [ + 'type' => 'Point', + 'coordinates' => [ + (float) $desa->lng, + (float) $desa->lat, + ], ], - ], - 'properties' => $this->properties($desa), - 'id' => $desa->id, - ]; - }); + 'properties' => $this->properties($desa), + 'id' => $desa->id, + ]; + }); return response()->json([ 'type' => 'FeatureCollection', 'features' => $geoJSONdata, ]); - } + } } private function properties($desa) diff --git a/app/Http/Controllers/LaporanController.php b/app/Http/Controllers/LaporanController.php index 667d0b50..e8c407b1 100644 --- a/app/Http/Controllers/LaporanController.php +++ b/app/Http/Controllers/LaporanController.php @@ -2,11 +2,11 @@ namespace App\Http\Controllers; +use App\Exports\DesaExport; use App\Models\Desa; use Illuminate\Http\Request; -use Yajra\DataTables\Facades\DataTables; use Maatwebsite\Excel\Facades\Excel; -use App\Exports\DesaExport; +use Yajra\DataTables\Facades\DataTables; class LaporanController extends Controller { @@ -20,9 +20,9 @@ public function __construct(Desa $desa) public function desa(Request $request) { - if($request->excel){ - $paramDatatable = json_decode($request->get('params'), 1); - $request->merge($paramDatatable); + if ($request->excel) { + $paramDatatable = json_decode($request->get('params'), 1); + $request->merge($paramDatatable); } $fillters = [ @@ -33,21 +33,24 @@ public function desa(Request $request) 'akses' => $request->akses, 'versi_lokal' => $request->versi_lokal, 'versi_hosting' => $request->versi_hosting, - 'tte' => $request->tte, - ]; + 'tte' => $request->tte, + ]; - if ($request->ajax() || $request->excel) { + if ($request->ajax() || $request->excel) { $query = DataTables::of($this->desa->fillter($fillters)->laporan()); - if($request->excel){ + if ($request->excel) { $query->filtering(); - return Excel::download(new DesaExport($query->results()), 'Desa-yang-memasang-OpenSID.xlsx');; + + return Excel::download(new DesaExport($query->results()), 'Desa-yang-memasang-OpenSID.xlsx'); } + return $query->addIndexColumn() - ->editColumn('kontak', function($q){ + ->editColumn('kontak', function ($q) { $identitas = $q->kontak; - if($identitas){ - return '
'.$identitas['nama'].'
'. $identitas['hp'].'
'; + if ($identitas) { + return '
'.$identitas['nama'].'
'.$identitas['hp'].'
'; } + return ''; }) ->addColumn('action', function ($data) { @@ -56,11 +59,9 @@ public function desa(Request $request) return '
'.$delete.'
'; }) ->rawColumns(['action', 'kontak']) - ->make(true); + ->make(true); } - - return view('laporan.desa', compact('fillters')); } diff --git a/app/Http/Controllers/LaporanDesaAktifController.php b/app/Http/Controllers/LaporanDesaAktifController.php index 390f45ee..1bfe6622 100644 --- a/app/Http/Controllers/LaporanDesaAktifController.php +++ b/app/Http/Controllers/LaporanDesaAktifController.php @@ -8,8 +8,7 @@ use Yajra\DataTables\Facades\DataTables; class LaporanDesaAktifController extends Controller -{ - +{ public function index(Request $request) { $fillters = [ @@ -25,8 +24,9 @@ public function index(Request $request) if ($request->ajax()) { $_30HariLalu = Carbon::now()->subDays(30); - return DataTables::of(Desa::fillter($fillters)->withCount(['akses' => static fn($q) => $q->where('created_at', '>=', $_30HariLalu)])->where('updated_at', '>=', $_30HariLalu)) - ->addIndexColumn() + + return DataTables::of(Desa::fillter($fillters)->withCount(['akses' => static fn ($q) => $q->where('created_at', '>=', $_30HariLalu)])->where('updated_at', '>=', $_30HariLalu)) + ->addIndexColumn() ->make(true); } diff --git a/app/Http/Controllers/LaporanTemaController.php b/app/Http/Controllers/LaporanTemaController.php index 261a9b8e..7a407646 100644 --- a/app/Http/Controllers/LaporanTemaController.php +++ b/app/Http/Controllers/LaporanTemaController.php @@ -3,13 +3,11 @@ namespace App\Http\Controllers; use App\Models\Desa; -use Carbon\Carbon; use Illuminate\Http\Request; use Yajra\DataTables\Facades\DataTables; class LaporanTemaController extends Controller -{ - +{ public function index(Request $request) { $fillters = [ @@ -26,15 +24,16 @@ public function index(Request $request) $tema = $request->query('tema', ''); if ($request->ajax()) { - if($tema){ + if ($tema) { $data = DataTables::of(Desa::fillter($fillters)->where('tema', $tema)); - }else{ + } else { $data = DataTables::of(Desa::fillter($fillters)->whereIn('tema', ['esensi', 'natra', 'palanta'])); } + return $data->addIndexColumn() - ->editColumn('updated_at', fn($q) => $q->updated_at->format('Y-m-d H:i:s')) + ->editColumn('updated_at', fn ($q) => $q->updated_at->format('Y-m-d H:i:s')) ->editColumn('url_hosting', function ($q) { - return ''. $q->url_hosting .''; + return ''.$q->url_hosting.''; }) ->rawColumns(['url_hosting']) // Mengizinkan HTML di kolom url_hosting ->make(true); diff --git a/app/Http/Controllers/LayananDesaDashboardController.php b/app/Http/Controllers/LayananDesaDashboardController.php index d5baec71..52e390a1 100644 --- a/app/Http/Controllers/LayananDesaDashboardController.php +++ b/app/Http/Controllers/LayananDesaDashboardController.php @@ -18,7 +18,8 @@ public function index(Request $request) 'kode_kecamatan' => $request->kode_kecamatan, ]; $versiTerakhir = lastrelease_api_layanandesa(); - $installHariIni = TrackMobile::with(['desa'])->whereDate('created_at', '>=',Carbon::now()->startOfYear()->format('Y-m-d'))->get(); + $installHariIni = TrackMobile::with(['desa'])->whereDate('created_at', '>=', Carbon::now()->startOfYear()->format('Y-m-d'))->get(); + return view('website.layanandesa.index', [ 'fillters' => $fillters, 'total_versi' => 2, @@ -28,7 +29,7 @@ public function index(Request $request) 'info_rilis' => 'Rilis LayananDesa '.$versiTerakhir, 'total_versi' => TrackMobile::distinct('versi')->count(), 'pengguna_versi_terakhir' => TrackMobile::where('versi', $versiTerakhir)->count(), - 'installHariIni' => $installHariIni + 'installHariIni' => $installHariIni, ]); } @@ -38,7 +39,7 @@ public function detail() } public function versi(Request $request) - { + { $fillters = [ 'kode_provinsi' => $request->kode_provinsi, 'kode_kabupaten' => $request->kode_kabupaten, @@ -46,7 +47,7 @@ public function versi(Request $request) ]; if ($request->ajax()) { - return DataTables::of(TrackMobile::groupBy('versi')->selectRaw('versi, count(*) as jumlah')) + return DataTables::of(TrackMobile::groupBy('versi')->selectRaw('versi, count(*) as jumlah')) ->addIndexColumn() ->make(true); } @@ -55,16 +56,17 @@ public function versi(Request $request) } public function versi_detail(Request $request) - { + { $fillters = [ 'kode_provinsi' => $request->kode_provinsi, 'kode_kabupaten' => $request->kode_kabupaten, 'kode_kecamatan' => $request->kode_kecamatan, ]; - + if ($request->ajax()) { $versi = $request->versi; - return DataTables::of(TrackMobile::filter($fillters)->when($versi, static fn($q) => $q->where('versi', $versi))->with(['desa'])->groupBy(['versi', 'kode_desa'])->selectRaw('kode_desa, versi, count(*) as jumlah')) + + return DataTables::of(TrackMobile::filter($fillters)->when($versi, static fn ($q) => $q->where('versi', $versi))->with(['desa'])->groupBy(['versi', 'kode_desa'])->selectRaw('kode_desa, versi, count(*) as jumlah')) ->addIndexColumn() ->make(true); } @@ -73,14 +75,14 @@ public function versi_detail(Request $request) } public function install_baru(Request $request) - { + { if ($request->ajax()) { return DataTables::of(TrackMobile::with('desa')->whereDate('created_at', '>=', Carbon::now()->subDays(7))) - ->editColumn('updated_at', static fn($q) => $q->updated_at->translatedFormat('j F Y H:i')) + ->editColumn('updated_at', static fn ($q) => $q->updated_at->translatedFormat('j F Y H:i')) ->addIndexColumn() ->make(true); - } - } + } + } public function summary(Request $request) { @@ -88,16 +90,16 @@ public function summary(Request $request) $provinsi = $request->get('provinsi'); $kabupaten = $request->get('kabupaten'); $kecamatan = $request->get('kecamatan'); - $summary = Desa::selectRaw('count(distinct kode_desa) as desa, count(distinct kode_kecamatan) as kecamatan, count(distinct kode_kabupaten) as kabupaten, count(distinct kode_provinsi) as provinsi')->whereIn('kode_desa', function($q){ + $summary = Desa::selectRaw('count(distinct kode_desa) as desa, count(distinct kode_kecamatan) as kecamatan, count(distinct kode_kabupaten) as kabupaten, count(distinct kode_provinsi) as provinsi')->whereIn('kode_desa', function ($q) { return $q->selectRaw('distinct kode_desa')->from('track_mobile'); }); - $summarySebelumnya = Desa::selectRaw('count(distinct kode_desa) as desa, count(distinct kode_kecamatan) as kecamatan, count(distinct kode_kabupaten) as kabupaten, count(distinct kode_provinsi) as provinsi')->whereIn('kode_desa', function($q){ + $summarySebelumnya = Desa::selectRaw('count(distinct kode_desa) as desa, count(distinct kode_kecamatan) as kecamatan, count(distinct kode_kabupaten) as kabupaten, count(distinct kode_provinsi) as provinsi')->whereIn('kode_desa', function ($q) { return $q->selectRaw('distinct kode_desa')->from('track_mobile'); }); $tanggalAkhir = explode(' - ', $period)[1]; $summary->where('created_at', '<=', $tanggalAkhir); - $summarySebelumnya->where('created_at', '<=', Carbon::parse($tanggalAkhir)->subMonth()->format('Y-m-d')); + $summarySebelumnya->where('created_at', '<=', Carbon::parse($tanggalAkhir)->subMonth()->format('Y-m-d')); if ($provinsi) { $summary->where('kode_provinsi', $provinsi); @@ -120,8 +122,8 @@ public function summary(Request $request) 'kabupaten' => ['total' => $summareResult->kabupaten, 'pertumbuhan' => $summareResult->kabupaten - $summarySebelumnyaResult->kabupaten], 'kecamatan' => ['total' => $summareResult->kecamatan, 'pertumbuhan' => $summareResult->kecamatan - $summarySebelumnyaResult->kecamatan], 'desa' => ['total' => $summareResult->desa, 'pertumbuhan' => $summareResult->desa - $summarySebelumnyaResult->desa], - ], - ] + ], + ] ); } @@ -131,46 +133,46 @@ public function peta(Request $request) $fillters = [ 'kode_provinsi' => $request->kode_provinsi, 'kode_kabupaten' => $request->kode_kabupaten, - 'kode_kecamatan' => $request->kode_kecamatan, + 'kode_kecamatan' => $request->kode_kecamatan, 'status' => null, 'akses' => null, 'versi_lokal' => null, 'versi_hosting' => null, - 'tte' => null, + 'tte' => null, ]; $geoJSONdata = Desa::fillter($fillters) ->whereRaw("CONCAT('',lat * 1) = lat") // tdk ikut sertakan data bukan bilangan ->whereRaw("CONCAT('',lng * 1) = lng") // tdk ikut sertakan data bukan bilangan ->whereRaw('lat BETWEEN -10 AND 6') - ->whereRaw('lng BETWEEN 95 AND 142') + ->whereRaw('lng BETWEEN 95 AND 142') ->where(function ($query) { $query ->where('lat', '!=', config('tracksid.desa_contoh.lat')) ->where('lng', '!=', config('tracksid.desa_contoh.lng')); - }) - ->whereIn('kode_desa', function($q){ + }) + ->whereIn('kode_desa', function ($q) { return $q->selectRaw('distinct kode_desa')->from('track_mobile'); })->orderBy('kode_desa', 'ASC')->get()->map(function ($desa) { - return [ - 'type' => 'Feature', - 'geometry' => [ - 'type' => 'Point', - 'coordinates' => [ - (float) $desa->lng, - (float) $desa->lat, + return [ + 'type' => 'Feature', + 'geometry' => [ + 'type' => 'Point', + 'coordinates' => [ + (float) $desa->lng, + (float) $desa->lat, + ], ], - ], - 'properties' => $this->properties($desa), - 'id' => $desa->id, - ]; - }); + 'properties' => $this->properties($desa), + 'id' => $desa->id, + ]; + }); return response()->json([ 'type' => 'FeatureCollection', 'features' => $geoJSONdata, ]); - } + } } private function properties($desa) diff --git a/app/Http/Controllers/MobileController.php b/app/Http/Controllers/MobileController.php index 8681afd4..5ee01f11 100644 --- a/app/Http/Controllers/MobileController.php +++ b/app/Http/Controllers/MobileController.php @@ -2,16 +2,16 @@ namespace App\Http\Controllers; +use App\Exports\KelolaDesaExport; +use App\Exports\LayananDesaExport; use App\Models\Desa; use App\Models\TrackKeloladesa; use App\Models\TrackMobile; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Config; -use Yajra\DataTables\Facades\DataTables; use Maatwebsite\Excel\Facades\Excel; -use App\Exports\KelolaDesaExport; -use App\Exports\LayananDesaExport; +use Yajra\DataTables\Facades\DataTables; class MobileController extends Controller { @@ -76,9 +76,9 @@ public function index() public function pengguna(Request $request) { - if($request->excel){ - $paramDatatable = json_decode($request->get('params'), 1); - $request->merge($paramDatatable); + if ($request->excel) { + $paramDatatable = json_decode($request->get('params'), 1); + $request->merge($paramDatatable); } $fillters = [ @@ -87,12 +87,14 @@ public function pengguna(Request $request) 'akses_mobile' => $request->akses_mobile, ]; - if ($request->ajax() || $request->excel) { + if ($request->ajax() || $request->excel) { $query = DataTables::of(TrackMobile::wilayahKhusus()->filter($fillters)->with(['desa'])); - if($request->excel){ + if ($request->excel) { $query->filtering(); - return Excel::download(new LayananDesaExport($query->results()), 'Desa-yang-memasang-Layanan-Desa.xlsx');; + + return Excel::download(new LayananDesaExport($query->results()), 'Desa-yang-memasang-Layanan-Desa.xlsx'); } + return $query->addIndexColumn() ->make(true); } @@ -102,9 +104,9 @@ public function pengguna(Request $request) public function penggunaKelolaDesa(Request $request) { - if($request->excel){ - $paramDatatable = json_decode($request->get('params'), 1); - $request->merge($paramDatatable); + if ($request->excel) { + $paramDatatable = json_decode($request->get('params'), 1); + $request->merge($paramDatatable); } $fillters = [ @@ -112,12 +114,14 @@ public function penggunaKelolaDesa(Request $request) 'kode_kabupaten' => $request->kode_kabupaten, 'akses_mobile' => $request->akses_mobile, ]; - if ($request->ajax() || $request->excel) { + if ($request->ajax() || $request->excel) { $query = DataTables::of(TrackKeloladesa::wilayahKhusus()->filter($fillters)->with(['desa'])); - if($request->excel){ + if ($request->excel) { $query->filtering(); - return Excel::download(new KelolaDesaExport($query->results()), 'Desa-yang-memasang-Kelola-Desa.xlsx');; + + return Excel::download(new KelolaDesaExport($query->results()), 'Desa-yang-memasang-Kelola-Desa.xlsx'); } + return $query->addIndexColumn() ->make(true); } diff --git a/app/Http/Controllers/OpenDKDashboardController.php b/app/Http/Controllers/OpenDKDashboardController.php index 70dea51a..251f5e3a 100644 --- a/app/Http/Controllers/OpenDKDashboardController.php +++ b/app/Http/Controllers/OpenDKDashboardController.php @@ -18,12 +18,13 @@ public function index(Request $request) 'kode_kecamatan' => $request->kode_kecamatan, ]; $versiTerakhir = lastrelease_opendk(); - $installHariIni = Opendk::whereDate('created_at', '>=',Carbon::now()->format('Y-m-d'))->get(); + $installHariIni = Opendk::whereDate('created_at', '>=', Carbon::now()->format('Y-m-d'))->get(); + return view('website.opendk.index', [ - 'fillters' => $fillters, + 'fillters' => $fillters, 'total_desa' => format_angka(Desa::count()), - 'pengguna_opendk' => Opendk::count(), - 'info_rilis' => 'Rilis OpenDK '.$versiTerakhir, + 'pengguna_opendk' => Opendk::count(), + 'info_rilis' => 'Rilis OpenDK '.$versiTerakhir, 'installHariIni' => $installHariIni, 'provinsi_pengguna_opendk' => Opendk::selectRaw('nama_provinsi, count(*) as total')->orderBy('total', 'desc')->groupBy('nama_provinsi')->get(), ]); @@ -35,7 +36,7 @@ public function detail() } public function versi(Request $request) - { + { $fillters = [ 'kode_provinsi' => $request->kode_provinsi, 'kode_kabupaten' => $request->kode_kabupaten, @@ -43,7 +44,7 @@ public function versi(Request $request) ]; if ($request->ajax()) { - return DataTables::of(Opendk::filter($fillters)->groupBy('versi')->selectRaw('versi, count(*) as jumlah')) + return DataTables::of(Opendk::filter($fillters)->groupBy('versi')->selectRaw('versi, count(*) as jumlah')) ->addIndexColumn() ->make(true); } @@ -52,17 +53,18 @@ public function versi(Request $request) } public function versi_detail(Request $request) - { + { $fillters = [ 'kode_provinsi' => $request->kode_provinsi, 'kode_kabupaten' => $request->kode_kabupaten, 'kode_kecamatan' => $request->kode_kecamatan, ]; - + if ($request->ajax()) { $versi = $request->versi; - return DataTables::of(Opendk::filter($fillters)->when($versi, static fn($q) => $q->where('versi', $versi))) - ->editColumn('updated_at', static fn($q) => $q->updated_at->translatedFormat('Y-m-d H:i:s')) + + return DataTables::of(Opendk::filter($fillters)->when($versi, static fn ($q) => $q->where('versi', $versi))) + ->editColumn('updated_at', static fn ($q) => $q->updated_at->translatedFormat('Y-m-d H:i:s')) ->addIndexColumn() ->make(true); } @@ -71,14 +73,14 @@ public function versi_detail(Request $request) } public function install_baru(Request $request) - { + { if ($request->ajax()) { return DataTables::of(Opendk::whereDate('created_at', '>=', Carbon::now()->subDays(7))) - ->editColumn('created_at', static fn($q) => $q->created_at->translatedFormat('j F Y H:i')) + ->editColumn('created_at', static fn ($q) => $q->created_at->translatedFormat('j F Y H:i')) ->addIndexColumn() ->make(true); - } - } + } + } public function peta(Request $request) { @@ -86,38 +88,38 @@ public function peta(Request $request) $fillters = [ 'kode_provinsi' => $request->kode_provinsi, 'kode_kabupaten' => $request->kode_kabupaten, - 'kode_kecamatan' => $request->kode_kecamatan + 'kode_kecamatan' => $request->kode_kecamatan, ]; - // + // $geoJSONdata = Opendk::filter($fillters) ->whereRaw("CONCAT('',lat * 1) = lat") // tdk ikut sertakan data bukan bilangan ->whereRaw("CONCAT('',lng * 1) = lng") // tdk ikut sertakan data bukan bilangan ->whereRaw('lat BETWEEN -10 AND 6') - ->whereRaw('lng BETWEEN 95 AND 142') + ->whereRaw('lng BETWEEN 95 AND 142') ->where(function ($query) { $query ->where('lat', '!=', config('tracksid.desa_contoh.lat')) ->where('lng', '!=', config('tracksid.desa_contoh.lng')); })->orderBy('kode_kecamatan', 'ASC')->get()->map(function ($kecamatan) { - return [ - 'type' => 'Feature', - 'geometry' => [ - 'type' => 'Point', - 'coordinates' => [ - (float) $kecamatan->lng, - (float) $kecamatan->lat, + return [ + 'type' => 'Feature', + 'geometry' => [ + 'type' => 'Point', + 'coordinates' => [ + (float) $kecamatan->lng, + (float) $kecamatan->lat, + ], ], - ], - 'properties' => $this->properties($kecamatan), - 'id' => $kecamatan->id, - ]; - }); + 'properties' => $this->properties($kecamatan), + 'id' => $kecamatan->id, + ]; + }); return response()->json([ 'type' => 'FeatureCollection', 'features' => $geoJSONdata, ]); - } + } } private function properties(Opendk $kecamatan) diff --git a/app/Http/Controllers/OpendkController.php b/app/Http/Controllers/OpendkController.php index 63bbe3dd..d6485c22 100644 --- a/app/Http/Controllers/OpendkController.php +++ b/app/Http/Controllers/OpendkController.php @@ -2,13 +2,13 @@ namespace App\Http\Controllers; +use App\Exports\OpenDKExport; use App\Models\Opendk; use App\Models\Region; use Illuminate\Http\Request; use Illuminate\Support\Facades\Config; -use Yajra\DataTables\Facades\DataTables; use Maatwebsite\Excel\Facades\Excel; -use App\Exports\OpenDKExport; +use Yajra\DataTables\Facades\DataTables; class OpendkController extends Controller { @@ -72,9 +72,9 @@ public function versi(Request $request) public function kecamatan(Request $request) { - if($request->excel){ - $paramDatatable = json_decode($request->get('params'), 1); - $request->merge($paramDatatable); + if ($request->excel) { + $paramDatatable = json_decode($request->get('params'), 1); + $request->merge($paramDatatable); } $fillters = [ @@ -85,12 +85,14 @@ public function kecamatan(Request $request) ]; $listVersi = $this->getListVersion(); - if ($request->ajax() || $request->excel) { + if ($request->ajax() || $request->excel) { $query = DataTables::of(Opendk::wilayahkhusus()->kecamatan($request)->selectRaw('updated_at as format_updated_at')); - if($request->excel){ + if ($request->excel) { $query->filtering(); - return Excel::download(new OpenDKExport($query->results()), 'Desa-yang-memasang-OpenDK.xlsx');; + + return Excel::download(new OpenDKExport($query->results()), 'Desa-yang-memasang-OpenDK.xlsx'); } + return $query->addIndexColumn() ->make(true); } diff --git a/app/Http/Controllers/OpenkabController.php b/app/Http/Controllers/OpenkabController.php index a6cc670d..52d88ae5 100644 --- a/app/Http/Controllers/OpenkabController.php +++ b/app/Http/Controllers/OpenkabController.php @@ -2,9 +2,8 @@ namespace App\Http\Controllers; -use App\Models\Opendk; -use GuzzleHttp\Client; use App\Models\Openkab; +use GuzzleHttp\Client; use Illuminate\Http\Request; use Illuminate\Support\Facades\Config; use Yajra\DataTables\Facades\DataTables; @@ -36,13 +35,13 @@ public function kerjaSama(Request $request) public function getWilayah() { - $url = config('layanan.uri') . '/api/v1/pelanggan/diskominfo'; + $url = config('layanan.uri').'/api/v1/pelanggan/diskominfo'; try { $client = new Client(); $response = $client->request('GET', $url, [ 'headers' => [ - 'Authorization' => 'Bearer ' . config('layanan.token'), + 'Authorization' => 'Bearer '.config('layanan.token'), 'Accept' => 'application/json', ], ]); @@ -51,9 +50,10 @@ public function getWilayah() $data = json_decode($body, true); if (Openkab::upsert($data, ['kode_kab'])) { return back()->with('success', 'Data Wilayah berhasil diperbarui'); - } + } } catch (\Exception $e) { report($e); + return back()->with('error', 'Data Wilayah gagal diperbarui'); } } diff --git a/app/Http/Controllers/PbbController.php b/app/Http/Controllers/PbbController.php index fb4da4ce..b3907b03 100644 --- a/app/Http/Controllers/PbbController.php +++ b/app/Http/Controllers/PbbController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers; use App\Models\Pbb; -use App\Models\Region; use Illuminate\Http\Request; use Illuminate\Support\Facades\Config; use Yajra\DataTables\Facades\DataTables; @@ -39,9 +38,9 @@ public function versi(Request $request) public function kecamatan(Request $request) { - if($request->excel){ - $paramDatatable = json_decode($request->get('params'), 1); - $request->merge($paramDatatable); + if ($request->excel) { + $paramDatatable = json_decode($request->get('params'), 1); + $request->merge($paramDatatable); } $fillters = [ @@ -52,9 +51,9 @@ public function kecamatan(Request $request) ]; $listVersi = $this->getListVersion(); - if ($request->ajax() || $request->excel) { + if ($request->ajax() || $request->excel) { $query = DataTables::of(Pbb::wilayahkhusus()->kecamatan($request)->selectRaw('updated_at as format_updated_at')); - + return $query->addIndexColumn() ->addColumn('action', function ($data) { $delete = ''; @@ -62,7 +61,7 @@ public function kecamatan(Request $request) return '
'.$delete.'
'; }) ->rawColumns(['action']) - ->make(true); + ->make(true); } return view($this->baseView.'.kecamatan', compact('fillters', 'listVersi')); @@ -96,7 +95,7 @@ private function getListVersion() return $item->versi; })->values()->all(); } - + public function deleteDesa(Pbb $desa) { if ($desa->delete()) { diff --git a/app/Http/Controllers/WebsiteDashboardController.php b/app/Http/Controllers/WebsiteDashboardController.php index b441cffe..a57d31ba 100644 --- a/app/Http/Controllers/WebsiteDashboardController.php +++ b/app/Http/Controllers/WebsiteDashboardController.php @@ -2,16 +2,16 @@ namespace App\Http\Controllers; -use Carbon\Carbon; use App\Models\Desa; use App\Models\Opendk; use App\Models\Openkab; use App\Models\Pbb; -use Carbon\CarbonPeriod; -use App\Models\TrackMobile; -use Illuminate\Http\Request; use App\Models\TrackKeloladesa; +use App\Models\TrackMobile; use App\Models\Wilayah; +use Carbon\Carbon; +use Carbon\CarbonPeriod; +use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Yajra\DataTables\Facades\DataTables; @@ -71,8 +71,8 @@ public function summary(Request $request) $layananWilayah = TrackMobile::where('created_at', '<=', $tanggalAkhir); $kelolaDesaWilayah = TrackKeloladesa::where('created_at', '<=', $tanggalAkhir); $versiTerakhirOpensid = collect(); - if($versiOpensid){ - $versiTerakhirOpensid = Desa::where(function($query) use ($versiOpensid){ + if ($versiOpensid) { + $versiTerakhirOpensid = Desa::where(function ($query) use ($versiOpensid) { return $query->where('versi_hosting', 'like', "{$versiOpensid}-premium%") ->orWhere('versi_lokal', 'like', "{$versiOpensid}-premium%"); }); @@ -113,10 +113,9 @@ public function summary(Request $request) $summareResult = $summary->first(); $summarySebelumnyaResult = $summarySebelumnya->first(); $totalVersiTerakhirOpensid = 0; - if($versiOpensid){ + if ($versiOpensid) { $totalVersiTerakhirOpensid = $versiTerakhirOpensid->count(); } - return response()->json([ 'total' => [ @@ -133,15 +132,15 @@ public function summary(Request $request) 'keloladesa' => $kelolaDesa ? $kelolaDesa->map(static fn ($q) => $q->desa->nama_desa)->toArray() : [], ], 'additional' => [ - 'opensid' => ['install_versi_terakhir' => $totalVersiTerakhirOpensid] + 'opensid' => ['install_versi_terakhir' => $totalVersiTerakhirOpensid], ], 'summary' => [ 'openkab' => $openkabWilayah->count(), 'opensid' => $opensidWilayah->count(), 'opendk' => $opendkWilayah->count(), 'layanandesa' => $layananWilayah->count(), - 'keloladesa' => $kelolaDesaWilayah->count() - ] + 'keloladesa' => $kelolaDesaWilayah->count(), + ], ] ); } @@ -245,7 +244,7 @@ public function chartUsage(Request $request, $data = false) ['label' => 'KelolaDesa', 'data' => $kelolaData], ]; } - + $result = [ 'labels' => $labels, 'datasets' => $datasets, @@ -258,7 +257,7 @@ public function layanandesa(Request $request) { return view('website.layanandesa'); } - + public function openkab(Request $request) { if ($request->ajax()) { @@ -277,19 +276,17 @@ public function openkab(Request $request) $latestDesa = 'Belum ada data'; } - $openkab = Openkab::select('kode_prov', 'nama_prov', DB::raw('count(kode_kab) as jumlah_kab')) ->groupBy('kode_prov') ->get(); - + $provinsi = []; - + foreach ($openkab as $kab) { - if (empty($kab->kode_prov)) { continue; // Skip data dengan kode_prov kosong } - + $total_kab = Wilayah::where('kode_prov', $kab->kode_prov) ->groupBY('kode_kab') ->get() @@ -300,12 +297,12 @@ public function openkab(Request $request) } else { $persentase = round(($kab->jumlah_kab / $total_kab) * 100, 2); } - + $provinsi[] = [ - 'kode_prov' => $kab->kode_prov, - 'nama_prov' => $kab->nama_prov, + 'kode_prov' => $kab->kode_prov, + 'nama_prov' => $kab->nama_prov, 'jumlah_kab' => $kab->jumlah_kab, - 'total_kab' => $total_kab, + 'total_kab' => $total_kab, 'persentase' => $persentase, ]; } @@ -320,8 +317,8 @@ public function openkab(Request $request) 'latestDesa' => $latestDesa, 'provinsi' => $sortedProvinsi->values()->all(), ]); - } - + } + public function openkabData(Request $request) { return view('website.openkab_data'); @@ -341,7 +338,7 @@ public function pbbData(Request $request) { return view('website.pbb_data'); } - + public function opensid(Request $request) { $fillters = [ @@ -349,21 +346,22 @@ public function opensid(Request $request) 'kode_kabupaten' => $request->kode_kabupaten, 'kode_kecamatan' => $request->kode_kecamatan, ]; - $totalInstall = Desa::count(); + $totalInstall = Desa::count(); $totalInstallOnline = Desa::online()->count(); - $installHariIni = Desa::whereDate('created_at', '>=',Carbon::now()->format('Y-m-d'))->get(); + $installHariIni = Desa::whereDate('created_at', '>=', Carbon::now()->format('Y-m-d'))->get(); + return view('website.opensid', [ 'fillters' => $fillters, 'total' => ['online' => $totalInstallOnline, 'offline' => $totalInstall - $totalInstallOnline], - 'installHariIni' => $installHariIni, + 'installHariIni' => $installHariIni, 'total_versi' => Desa::distinct('versi_hosting')->whereNotNull('versi_hosting')->count(), 'versi_terakhir' => lastrelease_opensid(), 'provinsi_pengguna_opensid' => Desa::selectRaw('nama_provinsi, count(*) as total')->orderBy('total', 'desc')->groupBy('nama_provinsi')->get(), 'pengguna_pbb' => Pbb::count(), 'versi_pbb' => lastrelease_pbb(), 'pengguna_anjungan' => Desa::anjungan()->count(), - 'latestPremiumVersion' => 'v' . lastrelease_opensid() . '-premium', - 'latestUmumVersion' => 'v' . lastrelease_opensid(), + 'latestPremiumVersion' => 'v'.lastrelease_opensid().'-premium', + 'latestUmumVersion' => 'v'.lastrelease_opensid(), 'statistikDesa' => Desa::jumlahDesa()->get()->first(), ]); } @@ -373,6 +371,7 @@ public function opensid_versi(Request $request) $fillters = [ 'aktif' => $request->aktif, ]; + return view('website.opensid_versi', compact('fillters')); } diff --git a/app/Http/Middleware/WebDashboard.php b/app/Http/Middleware/WebDashboard.php index 6bd3d282..eaaf9706 100644 --- a/app/Http/Middleware/WebDashboard.php +++ b/app/Http/Middleware/WebDashboard.php @@ -4,9 +4,9 @@ use Closure; use Illuminate\Http\Request; -use Illuminate\Support\Str; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Route; +use Illuminate\Support\Str; class WebDashboard { @@ -20,19 +20,20 @@ class WebDashboard public function handle(Request $request, Closure $next) { $route = Route::current(); - $uri = $route->uri(); + $uri = $route->uri(); - if (!auth()->check()) { - if(!Str::startsWith($uri, 'web') && $uri !== '/'){ + if (! auth()->check()) { + if (! Str::startsWith($uri, 'web') && $uri !== '/') { return redirect('web'); } - } + } // Change the config values here - Config::set('adminlte', Config::get('weblte')); // example - if(auth()->check()){ + Config::set('adminlte', Config::get('weblte')); // example + if (auth()->check()) { Config::set('adminlte.dashboard_url', 'dashboard'); } + return $next($request); } } diff --git a/app/Http/Requests/TrackKelolaDesaRequest.php b/app/Http/Requests/TrackKelolaDesaRequest.php index f3d81405..16243f8e 100644 --- a/app/Http/Requests/TrackKelolaDesaRequest.php +++ b/app/Http/Requests/TrackKelolaDesaRequest.php @@ -66,7 +66,7 @@ public function requestData() 'id_device', 'kode_desa', 'tgl_akses', - 'versi' + 'versi', ]); } } diff --git a/app/Http/Requests/TrackMobileRequest.php b/app/Http/Requests/TrackMobileRequest.php index b9712358..f24ef164 100644 --- a/app/Http/Requests/TrackMobileRequest.php +++ b/app/Http/Requests/TrackMobileRequest.php @@ -66,7 +66,7 @@ public function requestData() 'id', 'kode_desa', 'tgl_akses', - 'versi' + 'versi', ]); } } diff --git a/app/Http/Requests/TrackPBBRequest.php b/app/Http/Requests/TrackPBBRequest.php index fe3eabba..43642c5b 100644 --- a/app/Http/Requests/TrackPBBRequest.php +++ b/app/Http/Requests/TrackPBBRequest.php @@ -49,7 +49,7 @@ public function rules() 'url' => ['required', 'url', "not_regex:/{$this->listAbaikanDomain()}/"], 'versi' => 'required', ]; - } + } /** * List abikan domain. @@ -80,7 +80,7 @@ public function requestData() 'nama_kabupaten', 'nama_provinsi', 'url', - 'versi', + 'versi', ]); } } diff --git a/app/Http/Requests/TrackRequest.php b/app/Http/Requests/TrackRequest.php index 0c58a74d..95090d21 100644 --- a/app/Http/Requests/TrackRequest.php +++ b/app/Http/Requests/TrackRequest.php @@ -137,13 +137,13 @@ public function requestData() $kontak = [ 'nama' => $this->nama_kontak, 'hp' => $this->hp_kontak, - 'jabatan' => $this->jabatan_kontak + 'jabatan' => $this->jabatan_kontak, ]; $this->merge([ 'nama_kabupaten' => Region::where('region_code', $this->kode_kabupaten)->first()->region_name ?? $this->nama_kabupaten, 'nama_kecamatan' => Region::where('region_code', $this->kode_kecamatan)->first()->region_name ?? $this->nama_kecamatan, 'nama_desa' => Region::where('region_code', $this->kode_desa)->first()->region_name ?? $this->nama_desa, - 'kontak' => $kontak + 'kontak' => $kontak, ]); return $this->only([ @@ -181,8 +181,8 @@ public function requestData() 'jml_dokumen', 'jml_keluarga', 'anjungan', - 'kontak', - 'tema' + 'kontak', + 'tema', ]); } } diff --git a/app/Models/Desa.php b/app/Models/Desa.php index b9639780..17e5c01d 100644 --- a/app/Models/Desa.php +++ b/app/Models/Desa.php @@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; + class Desa extends Model { use HasFactory; @@ -25,7 +26,7 @@ class Desa extends Model 'tgl_akses_hosting' => 'datetime', 'kontak' => 'array', 'anjungan' => 'bool', - 'tema' => 'string' + 'tema' => 'string', ]; /** {@inheritdoc} */ @@ -395,8 +396,8 @@ public function scopeLatestPremiumVersion($query) CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(versi_hosting, '.', -2), '.', 1) AS UNSIGNED) DESC" )->first(); - $versi = $versi ? 'v' . $versi->versi_hosting : 'Belum ada data'; - + $versi = $versi ? 'v'.$versi->versi_hosting : 'Belum ada data'; + return $versi; } @@ -409,7 +410,7 @@ public function scopeLatestUmumVersion($query) CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(versi_hosting, '.', -2), '.', 1) AS UNSIGNED) DESC" )->first(); - $versi = $versi ? 'v' . $versi->versi_hosting : 'Belum ada data'; + $versi = $versi ? 'v'.$versi->versi_hosting : 'Belum ada data'; return $versi; } @@ -425,11 +426,13 @@ public function scopeAnjungan($query) return $query->where('anjungan', true); } - public function isPemdaHosting(){ + public function isPemdaHosting() + { return Str::endsWith($this->url_hosting, '.go.id'); } - public function isNew(){ + public function isNew() + { return $this->created_at->format('Y-m-d') == date('Y-m-d'); } diff --git a/app/Models/Opendk.php b/app/Models/Opendk.php index ef6c5443..56185d0b 100644 --- a/app/Models/Opendk.php +++ b/app/Models/Opendk.php @@ -163,8 +163,8 @@ public function scopeAktif($query, $batasTgl) public function scopeFilter($query, array $fillters) { return $query->when($fillters['kode_provinsi'] ?? false, function ($query, $kode_provinsi) { - $query->where('kode_provinsi', $kode_provinsi); - }) + $query->where('kode_provinsi', $kode_provinsi); + }) ->when($fillters['kode_kabupaten'] ?? false, function ($query, $kode_kabupaten) { $query->where('kode_kabupaten', $kode_kabupaten); }) diff --git a/app/Models/Openkab.php b/app/Models/Openkab.php index 073274f5..ffb38747 100644 --- a/app/Models/Openkab.php +++ b/app/Models/Openkab.php @@ -2,18 +2,18 @@ namespace App\Models; -use Illuminate\Support\Str; -use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Str; class Openkab extends Model { use HasFactory; - /** {@inheritdoc} */ - protected $table = 'openkab'; + /** {@inheritdoc} */ + protected $table = 'openkab'; - /** {@inheritdoc} */ + /** {@inheritdoc} */ protected $primaryKey = 'kode_kab'; /** {@inheritdoc} */ @@ -22,7 +22,7 @@ class Openkab extends Model /** {@inheritdoc} */ public $incrementing = false; - protected $fillable = [ + protected $fillable = [ 'kode_kab', 'nama_kab', 'kode_prov', @@ -57,7 +57,7 @@ public function getNamaWilayahAttribute() if (Str::contains($namaKab, $sebutanKab)) { return $namaKab; } else { - return $sebutanKab . ' ' . $namaKab; + return $sebutanKab.' '.$namaKab; } } @@ -80,5 +80,4 @@ public function latestDesaVersion() { return $this->desa()->latestVersion(); } - } diff --git a/app/Models/Pbb.php b/app/Models/Pbb.php index 7f6fb3fe..1a2d4c64 100644 --- a/app/Models/Pbb.php +++ b/app/Models/Pbb.php @@ -9,9 +9,9 @@ class Pbb extends Model { use HasFactory; - + const ACTIVE_DAYS = 7; - + /** {@inheritdoc} */ protected $table = 'pbb'; diff --git a/app/Models/TrackKeloladesa.php b/app/Models/TrackKeloladesa.php index 7f55e68d..a37228fc 100644 --- a/app/Models/TrackKeloladesa.php +++ b/app/Models/TrackKeloladesa.php @@ -114,17 +114,17 @@ public function scopeAktif($query, $batasTgl) } public function scopeProvinsi($query, $provinsi) - { + { return $query->whereRaw('left(kode_desa, 2) = \''.$provinsi.'\''); } public function scopeKabupaten($query, $kabupaten) - { + { return $query->whereRaw('left(kode_desa, 5) = \''.$kabupaten.'\''); } public function scopeKecamatan($query, $kecamatan) - { + { return $query->whereRaw('left(kode_desa, 8) = \''.$kecamatan.'\''); } } diff --git a/app/Models/TrackMobile.php b/app/Models/TrackMobile.php index a2ada2b0..f9a8be32 100644 --- a/app/Models/TrackMobile.php +++ b/app/Models/TrackMobile.php @@ -114,17 +114,17 @@ public function scopeAktif($query, $batasTgl) } public function scopeProvinsi($query, $provinsi) - { + { return $query->whereRaw('left(kode_desa, 2) = \''.$provinsi.'\''); } public function scopeKabupaten($query, $kabupaten) - { + { return $query->whereRaw('left(kode_desa, 5) = \''.$kabupaten.'\''); } public function scopeKecamatan($query, $kecamatan) - { + { return $query->whereRaw('left(kode_desa, 8) = \''.$kecamatan.'\''); - } + } } diff --git a/app/Providers/CustomTelegramServiceProvider.php b/app/Providers/CustomTelegramServiceProvider.php index eb765fe3..66865c71 100644 --- a/app/Providers/CustomTelegramServiceProvider.php +++ b/app/Providers/CustomTelegramServiceProvider.php @@ -6,7 +6,6 @@ use Illuminate\Notifications\ChannelManager; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Notification; -use Illuminate\Support\ServiceProvider; use NotificationChannels\Telegram\Telegram; use NotificationChannels\Telegram\TelegramChannel; use NotificationChannels\Telegram\TelegramServiceProvider; @@ -20,7 +19,7 @@ class CustomTelegramServiceProvider extends TelegramServiceProvider * Register the application services. */ public function register(): void - { + { $this->app->bind(Telegram::class, static fn () => new Telegram( Cache::get('token_bot_telegram', null), app(HttpClient::class), diff --git a/catatan_rilis.md b/catatan_rilis.md index c57d43b6..9974cc12 100644 --- a/catatan_rilis.md +++ b/catatan_rilis.md @@ -1,15 +1,10 @@ Di rilis v2410.0.0 berisi perbaikan yang diminta Komunitas Open Desa. #### Penambahan Fitur -1. [#419](https://github.com/OpenSID/pantau/issues/419) Perbaikan halaman OpenDK. -2. [#427](https://github.com/OpenSID/pantau/issues/427) Penambahan API pantau tema dan tampilkan data tema di pantau. #### Perbaikan Bug -1. [#420](https://github.com/OpenSID/pantau/issues/420) Perbaikan route default pantau. +1. [#430](https://github.com/OpenSID/pantau/issues/430) Perbaikan permission file logging ketika backup otomatis. #### Penyesuaian Teknis -1. [#429](https://github.com/OpenSID/pantau/issues/429) Perbaikan performa query datatable pengguna OpenSID. -2. [#433](https://github.com/OpenSID/pantau/issues/433) Ijinkan akses web dashboard setelah login. -3. [#422](https://github.com/OpenSID/pantau/issues/422) Mutahirkan daftar wilayah berdasarkan permendagri yang baru.