-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
92 changed files
with
1,185 additions
and
659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.