-
-
Save muhghazaliakbar/d6d05c252d805aec2517b183728c5425 to your computer and use it in GitHub Desktop.
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
<?php | |
namespace AMS\RegistrasiSuratMagang; | |
use AMS\Models\SuratMasuk; | |
use Illuminate\Http\Request; | |
use AMS\Models\BodySuratKeluarMagang; | |
use AMS\Models\HeaderSuratKeluarMagang; | |
class RegistrasiSuratMagang | |
{ | |
public function make(Request $request) | |
{ | |
$suratMasuk = SuratMasuk::create([ | |
'no_surat' => $request->input('no-surat-masuk'), | |
'asal_surat' => $request->input('asal-surat'), | |
'perihal' => $request->input('perihal-surat-masuk'), | |
'created_at' => \Carbon\Carbon::now(), | |
'updated_at' => \Carbon\Carbon::now() | |
]); | |
// Transform data | |
foreach($request->get('r_nama') as $key => $val) { | |
$transformed_data[] = array( | |
'nama' => $request->get('r_nama')[$key], | |
'stambuk' => $request->get('r_stambuk')[$key], | |
'jenis_kelamin' => $request->get('r_jenis_kelamin')[$key], | |
'jurusan' => $request->get('r_jurusan')[$key] | |
); | |
} | |
$suratKeluar = HeaderSuratKeluarMagang::create([ | |
'id_surat_masuk' => $suratMasuk->id, | |
'no_surat' => $request->input('no-surat-keluar'), | |
'perihal' => $request->input('perihal-surat-keluar'), | |
'jenis_pengabdian' => $request->input('jenis-pengabdian'), | |
'jenjang_peserta' => $request->input('jenjang-peserta'), | |
'tujuan_surat_kantor' => $request->input('tujuan-surat-keluar-kantor'), | |
'tujuan_surat_kepala_kantor' => $request->input('tujuan-surat-keluar-kepala-kantor'), | |
'id_user_penandatangan' => $request->input('penandatangan'), | |
'created_at' => \Carbon\Carbon::now(), | |
'updated_at' => \Carbon\Carbon::now() | |
]); | |
foreach($transformed_data as $key => $val) | |
{ | |
$bodySuratKeluarMagang = BodySuratKeluarMagang::create([ | |
'id_header_surat_keluar_magang' => $suratKeluar->id, | |
'nama' => $val['nama'], | |
'stambuk' => $val['stambuk'], | |
'jenis_kelamin' => $val['jenis_kelamin'], | |
'jurusan' => $val['jurusan'], | |
'created_at' => \Carbon\Carbon::now(), | |
'updated_at' => \Carbon\Carbon::now() | |
]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment