Skip to content

Commit

Permalink
Rilis 2408 (#991)
Browse files Browse the repository at this point in the history
  • Loading branch information
habibie11 authored Aug 1, 2024
2 parents f6f76cc + 1fb2353 commit b823b0c
Show file tree
Hide file tree
Showing 92 changed files with 1,185 additions and 659 deletions.
60 changes: 60 additions & 0 deletions app/Exports/ExportPenduduk.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

/*
* Class ini digunakan untuk export data dalam bentuk file
*/

namespace App\Exports;

use App\Models\Penduduk;
use Illuminate\Support\Facades\DB;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;

class ExportPenduduk implements FromCollection, WithHeadings
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
$data = [];
$penduduks = Penduduk::with('desa', 'pendidikan_kk', 'pekerjaan', 'kawin')->get();

foreach ($penduduks as $penduduk) {
array_push($data, (object)[
'id' => $penduduk->id,
'nama' => $penduduk->nama,
'nik' => $penduduk->nik,
'no_kk' => $penduduk->no_kk,
'nama_desa' => $penduduk->desa->nama,
'alamat' => $penduduk->alamat,
'pendidikan' => $penduduk->pendidikan_kk->nama,
'tanggal_lahir' => $penduduk->tanggal_lahir,
'pekerjaan' => $penduduk->pekerjaan->nama,
'status_kawin' => $penduduk->pekerjaan->nama,
]);
}

return collect($data);
}

/**
* @return array
*/
public function headings(): array
{
return [
'ID',
'NAMA',
'NIK',
'NO.KK',
'DESA',
'ALAMAT',
'PENDIDIKAN DALAM KK',
'TANGGAL LAHIR',
'PEKERJAAN',
'STATUS KAWIN'
];
}
}
10 changes: 2 additions & 8 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use App\Models\Jabatan;
use App\Models\Keluarga;
use App\Models\MediaSosial;
use App\Models\Navigation;
use App\Models\Penduduk;
use App\Models\Pengurus;
use App\Models\Profil;
Expand Down Expand Up @@ -132,27 +133,20 @@ public function __construct()
// TODO : Gunakan untuk semua pengaturan jika sudah tersedia
$this->browser_title = SettingAplikasi::where('key', 'judul_aplikasi')->first()->value ?? ucwords($this->sebutan_wilayah.' '.$this->profil->nama_kecamatan);

$events = Event::getOpenEvents();
$sinergi = SinergiProgram::where('status', 1)->orderBy('urutan', 'asc')->get();
$medsos = MediaSosial::where('status', 1)->get();
$navdesa = DataDesa::all();
$navpotensi = TipePotensi::orderby('nama_kategori', 'ASC')->get();
$pengurus = Pengurus::status()->get();
$slides = Slide::orderBy('created_at', 'DESC')->get();


View::share([
'profil' => $this->profil,
'sebutan_wilayah' => $this->sebutan_wilayah,
'sebutan_kepala_wilayah' => $this->sebutan_kepala_wilayah,
'browser_title' => $this->browser_title,
'events' => $events,
'sinergi' => $sinergi,
'medsos' => $medsos,
'navdesa' => $navdesa,
'navpotensi' => $navpotensi,
'camat' => $this->nama_camat,
'pengurus' => $pengurus->sortBy('jabatan.jenis'),
'slides' => $slides,
]);
}
}
Expand Down
18 changes: 18 additions & 0 deletions app/Http/Controllers/Data/PendudukController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

namespace App\Http\Controllers\Data;

use Maatwebsite\Excel\Facades\Excel;

use App\Http\Controllers\Controller;
use App\Imports\ImporPendudukKeluarga;
use App\Models\DataDesa;
Expand All @@ -39,6 +41,7 @@
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
use Yajra\DataTables\DataTables;
use App\Exports\ExportPenduduk;

class PendudukController extends Controller
{
Expand Down Expand Up @@ -177,4 +180,19 @@ public function importExcel(Request $request)

return redirect()->route('data.penduduk.index')->with('success', 'Import data sukses.');
}

/**
* Export data penduduk ke dalam file Excel.
*
* @return Response
*/
public function exportExcel(Penduduk $penduduk) {
try {
return Excel::download(new ExportPenduduk, 'data-penduduk.xlsx');
} catch (\Exception $e) {
report($e);

return back()->with('error', 'Export data gagal. '.$e->getMessage());
}
}
}
15 changes: 15 additions & 0 deletions app/Http/Controllers/FrontEndController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,26 @@

namespace App\Http\Controllers;

use App\Models\Event;
use App\Models\Slide;
use App\Models\Navigation;
use App\Models\MediaSosial;
use App\Models\SinergiProgram;
use Illuminate\Support\Facades\View;

class FrontEndController extends Controller
{
public function __construct()
{
parent::__construct();
theme_active();

View::share([
'events' => Event::getOpenEvents(),
'medsos' => MediaSosial::where('status', 1)->get(),
'navigations' => Navigation::with('childrens')->whereNull('parent_id')->where('status', 1)->orderBy('order', 'asc')->get(),
'sinergi' => SinergiProgram::where('status', 1)->orderBy('urutan', 'asc')->get(),
'slides' => Slide::orderBy('created_at', 'DESC')->get(),
]);
}
}
Loading

0 comments on commit b823b0c

Please sign in to comment.