Commit e00ce48b authored by Syaifur Rohman's avatar Syaifur Rohman

fix siswa on delete

add ->whereHas('siswa') on relation
parent fcd1f358
...@@ -41,7 +41,7 @@ public function __construct() ...@@ -41,7 +41,7 @@ public function __construct()
// Di isi Construct // Di isi Construct
$this->mPeriode = New PeriodeModel(); $this->mPeriode = New PeriodeModel();
$this->mJabatan = New JabatanModel(); $this->mJabatan = New JabatanModel();
$this->mPerpusJurusan = new JurusanModel(); $this->mPerpusJurusan = new JurusanModel();
$this->mPerpusKelas = new KelasModel(); $this->mPerpusKelas = new KelasModel();
$this->mKelasKode = new KelasKodeModel(); $this->mKelasKode = new KelasKodeModel();
...@@ -66,7 +66,7 @@ public function __construct() ...@@ -66,7 +66,7 @@ public function __construct()
'idPSekolah' => session()->get('idPSekolah'), 'idPSekolah' => session()->get('idPSekolah'),
'idSKonselor' => session()->get('idSKonselor'), 'idSKonselor' => session()->get('idSKonselor'),
]; ];
$homevisit_kegiatan = $this->mHomevisitKegiatan->where($wherenyaa)->get(); $homevisit_kegiatan = $this->mHomevisitKegiatan->where($wherenyaa)->whereHas('siswa')->get();
$data = [ $data = [
'title' => $this->title, 'title' => $this->title,
...@@ -105,7 +105,7 @@ public function __construct() ...@@ -105,7 +105,7 @@ public function __construct()
if(!isset($kepsek)){ if(!isset($kepsek)){
return redirect("$this->url")->with('gagal', 'Kepsek belum di set'); return redirect("$this->url")->with('gagal', 'Kepsek belum di set');
}; };
$whereKons = [ $whereKons = [
'id' => $siswa['idSKonselor'], 'id' => $siswa['idSKonselor'],
'status' => 1, 'status' => 1,
...@@ -115,10 +115,10 @@ public function __construct() ...@@ -115,10 +115,10 @@ public function __construct()
return redirect("$this->url")->with('gagal', 'Guru Konseling belum di set atau tidak aktif'); return redirect("$this->url")->with('gagal', 'Guru Konseling belum di set atau tidak aktif');
}; };
$suratWaktu = $request->surat_waktu; $suratWaktu = $request->surat_waktu;
$suratWaktunew = date("d-m-Y", strtotime($suratWaktu)); $suratWaktunew = date("d-m-Y", strtotime($suratWaktu));
$isianWaktu = $request->isian_waktu; $isianWaktu = $request->isian_waktu;
$isianWaktunew = date("d-m-Y", strtotime($isianWaktu)); $isianWaktunew = date("d-m-Y", strtotime($isianWaktu));
$dataHomevisitKegiatan = [ $dataHomevisitKegiatan = [
...@@ -157,7 +157,7 @@ public function __construct() ...@@ -157,7 +157,7 @@ public function __construct()
]; ];
// dd($dataHomevisitRpl); die(); // dd($dataHomevisitRpl); die();
$this->mHomevisitRpl->create($dataHomevisitRpl); $this->mHomevisitRpl->create($dataHomevisitRpl);
return redirect("$this->url")->with('sukses', 'Data Layanan Homevisit Rpl berhasil di tambahkan'); return redirect("$this->url")->with('sukses', 'Data Layanan Homevisit Rpl berhasil di tambahkan');
} }
...@@ -169,7 +169,7 @@ public function __construct() ...@@ -169,7 +169,7 @@ public function __construct()
$homevisit_tu = $this->mHomevisitTu->where('idLHKegiatan', $homevisit_kegiatan->id)->first(); $homevisit_tu = $this->mHomevisitTu->where('idLHKegiatan', $homevisit_kegiatan->id)->first();
// $guru = $this->mGuru->where('id', $homevisit_tu['arrayIdSGuru'])->first(); // ambil data guru berdasarkan homvisit tu // $guru = $this->mGuru->where('id', $homevisit_tu['arrayIdSGuru'])->first(); // ambil data guru berdasarkan homvisit tu
// $jabatan = $this->mJabatan->where('id', $homevisit_tu['arrayJabatan'])->first(); // ambil data guru berdasarkan homvisit tu // $jabatan = $this->mJabatan->where('id', $homevisit_tu['arrayJabatan'])->first(); // ambil data guru berdasarkan homvisit tu
$data = [ $data = [
'title' => $this->title, 'title' => $this->title,
'url' => $this->url, 'url' => $this->url,
......
...@@ -25,7 +25,7 @@ use PhpOffice\PhpWord\TemplateProcessor; ...@@ -25,7 +25,7 @@ use PhpOffice\PhpWord\TemplateProcessor;
class SPMundurController extends Controller class SPMundurController extends Controller
{ {
private $views = 'admin/layanan/surat/sp_mundur'; private $views = 'admin/layanan/surat/sp_mundur';
private $url = 'admin/layanan/surat/pernyataan/mundur'; private $url = 'admin/layanan/surat/pernyataan/mundur';
private $title = 'Halaman Form Pernyataan Mundur'; private $title = 'Halaman Form Pernyataan Mundur';
...@@ -56,7 +56,7 @@ public function __construct() ...@@ -56,7 +56,7 @@ public function __construct()
'idPSekolah' => session()->get('idPSekolah'), 'idPSekolah' => session()->get('idPSekolah'),
'idSKonselor' => session()->get('idSKonselor'), 'idSKonselor' => session()->get('idSKonselor'),
]; ];
$mundur = $this->mMundur->where($wherenyaa)->get(); $mundur = $this->mMundur->where($wherenyaa)->whereHas('siswa')->get();
$data = [ $data = [
'title' => $this->title, 'title' => $this->title,
...@@ -129,8 +129,8 @@ public function __construct() ...@@ -129,8 +129,8 @@ public function __construct()
return redirect("$this->url")->with('gagal', 'Guru Konseling belum di set atau tidak aktif'); return redirect("$this->url")->with('gagal', 'Guru Konseling belum di set atau tidak aktif');
}; };
$suratWaktu = $request->surat_waktu; $suratWaktu = $request->surat_waktu;
$suratWaktunew = date("d-m-Y", strtotime($suratWaktu)); $suratWaktunew = date("d-m-Y", strtotime($suratWaktu));
$dataMundur = [ $dataMundur = [
'idPSekolah' => session()->get('idPSekolah'), 'idPSekolah' => session()->get('idPSekolah'),
'idSKonselor' => session()->get('idSKonselor'), 'idSKonselor' => session()->get('idSKonselor'),
...@@ -154,15 +154,15 @@ public function __construct() ...@@ -154,15 +154,15 @@ public function __construct()
'page' => 'Data Surat Pernyataan Mundur', 'page' => 'Data Surat Pernyataan Mundur',
'mundur' => $mundur, 'mundur' => $mundur,
]; ];
return view($this->views . "/show", $data); return view($this->views . "/show", $data);
} }
public function show($id) public function show($id)
{ {
// Get Data // Get Data
$mundur = $this->mMundur->where('kode_unik', $id)->first(); $mundur = $this->mMundur->where('kode_unik', $id)->first();
$data = [ $data = [
'title' => $this->title, 'title' => $this->title,
'url' => $this->url, 'url' => $this->url,
...@@ -190,7 +190,7 @@ public function __construct() ...@@ -190,7 +190,7 @@ public function __construct()
'alamatOrtu' => $mundur->ortu->alamat, 'alamatOrtu' => $mundur->ortu->alamat,
'pekerjaan' => $mundur->ortu->pekerjaan->nama, 'pekerjaan' => $mundur->ortu->pekerjaan->nama,
'surat_tempat' => $mundur->surat_tempat, 'surat_tempat' => $mundur->surat_tempat,
'surat_waktu' => $mundur->surat_waktu, 'surat_waktu' => $mundur->surat_waktu,
'idSWali' => $mundur->wali->guru->nama ?? 'Wali belum di SET', 'idSWali' => $mundur->wali->guru->nama ?? 'Wali belum di SET',
'nipWali' => $mundur->wali->guru->nip ?? 'Wali belum di SET', 'nipWali' => $mundur->wali->guru->nip ?? 'Wali belum di SET',
'idSKonselor' => $mundur->konselor->guru->nama ?? 'Guru Konseling belum di SET', 'idSKonselor' => $mundur->konselor->guru->nama ?? 'Guru Konseling belum di SET',
...@@ -203,37 +203,37 @@ public function __construct() ...@@ -203,37 +203,37 @@ public function __construct()
// pakai dari sini. sambil buka word coba.docx // pakai dari sini. sambil buka word coba.docx
$templateProcessor = new TemplateProcessor('word-template/surat/surat_pernyataan_mundur.docx'); // load template word $templateProcessor = new TemplateProcessor('word-template/surat/surat_pernyataan_mundur.docx'); // load template word
$templateProcessor->setImageValue('KopSurat', array('path' => "upload/logo_sekolah/".$datamundur['KopSurat'], 'width' => 500, 'height' => 200, 'ratio' => true)); $templateProcessor->setImageValue('KopSurat', array('path' => "upload/logo_sekolah/".$datamundur['KopSurat'], 'width' => 500, 'height' => 200, 'ratio' => true));
$templateProcessor->setValue('namaSekolah', $datamundur['namaSekolah']); $templateProcessor->setValue('namaSekolah', $datamundur['namaSekolah']);
$templateProcessor->setValue('namaSiswa', $datamundur['idSiswa']); $templateProcessor->setValue('namaSiswa', $datamundur['idSiswa']);
$templateProcessor->setValue('kelasSiswa', $datamundur['idPKKode']); $templateProcessor->setValue('kelasSiswa', $datamundur['idPKKode']);
$templateProcessor->setValue('nisn', $datamundur['nisn']); $templateProcessor->setValue('nisn', $datamundur['nisn']);
$templateProcessor->setValue('namaOrtu', $datamundur['idOrtu']); $templateProcessor->setValue('namaOrtu', $datamundur['idOrtu']);
$templateProcessor->setValue('alamatOrtu', $datamundur['alamatOrtu']); $templateProcessor->setValue('alamatOrtu', $datamundur['alamatOrtu']);
$templateProcessor->setValue('pekerjaan', $datamundur['pekerjaan']); $templateProcessor->setValue('pekerjaan', $datamundur['pekerjaan']);
$templateProcessor->setValue('surat_tempat', $datamundur['surat_tempat']); $templateProcessor->setValue('surat_tempat', $datamundur['surat_tempat']);
$templateProcessor->setValue('tanggalSurat', $datamundur['surat_waktu']); $templateProcessor->setValue('tanggalSurat', $datamundur['surat_waktu']);
$templateProcessor->setValue('namaWaliKelas', $datamundur['idSWali']); $templateProcessor->setValue('namaWaliKelas', $datamundur['idSWali']);
$templateProcessor->setValue('nipWaliKelas', $datamundur['nipWali']); $templateProcessor->setValue('nipWaliKelas', $datamundur['nipWali']);
$templateProcessor->setValue('namaKonselor', $datamundur['idSKonselor']); $templateProcessor->setValue('namaKonselor', $datamundur['idSKonselor']);
$templateProcessor->setValue('nipKonselor', $datamundur['nipKonselor']); $templateProcessor->setValue('nipKonselor', $datamundur['nipKonselor']);
$templateProcessor->setValue('namaKonselor', $datamundur['idSKonselor']); $templateProcessor->setValue('namaKonselor', $datamundur['idSKonselor']);
$templateProcessor->setValue('nipKonselor', $datamundur['nipKonselor']); $templateProcessor->setValue('nipKonselor', $datamundur['nipKonselor']);
$templateProcessor->setValue('namaWakaKesiswaan', $datamundur['idSKesiswaan']); $templateProcessor->setValue('namaWakaKesiswaan', $datamundur['idSKesiswaan']);
$templateProcessor->setValue('nipWakaKesiswaan', $datamundur['nipKesiswaan']); $templateProcessor->setValue('nipWakaKesiswaan', $datamundur['nipKesiswaan']);
$templateProcessor->setValue('namaKepsek', $datamundur['idSKepsek']); $templateProcessor->setValue('namaKepsek', $datamundur['idSKepsek']);
$templateProcessor->setValue('nipKepsek', $datamundur['nipKepsek']); $templateProcessor->setValue('nipKepsek', $datamundur['nipKepsek']);
$fileName = 'Surat Siswa mundur'; // nama filenya $fileName = 'Surat Siswa mundur'; // nama filenya
// biar bisa dunlud // biar bisa dunlud
$templateProcessor->saveAs('tempor/' . $fileName . '.docx'); $templateProcessor->saveAs('tempor/' . $fileName . '.docx');
return response()->download('tempor/' . $fileName . '.docx')->deleteFileAfterSend(true); return response()->download('tempor/' . $fileName . '.docx')->deleteFileAfterSend(true);
// dd($datamundur); // dd($datamundur);
} }
public function edit($id){ public function edit($id){
$mundur = $this->mMundur->where('kode_unik', $id)->first(); $mundur = $this->mMundur->where('kode_unik', $id)->first();
$data = [ $data = [
'title' => $this->title, 'title' => $this->title,
'url' => $this->url, 'url' => $this->url,
...@@ -253,7 +253,7 @@ public function __construct() ...@@ -253,7 +253,7 @@ public function __construct()
$suratWaktu = $request->surat_waktu; $suratWaktu = $request->surat_waktu;
$suratWaktunew = date("d-m-Y", strtotime($suratWaktu)); $suratWaktunew = date("d-m-Y", strtotime($suratWaktu));
} else { } else {
$suratWaktunew = $dataUbah->surat_waktu; $suratWaktunew = $dataUbah->surat_waktu;
} }
$dataMundur = [ $dataMundur = [
...@@ -271,7 +271,7 @@ public function __construct() ...@@ -271,7 +271,7 @@ public function __construct()
'surat_tempat' => $request->surat_tempat, 'surat_tempat' => $request->surat_tempat,
'surat_waktu' => $suratWaktunew, 'surat_waktu' => $suratWaktunew,
]; ];
$this->mMundur->where('kode_unik', $id)->update($dataMundur); $this->mMundur->where('kode_unik', $id)->update($dataMundur);
return redirect("$this->url")->with('sukses', 'Data Surat Keterangan Mundur untuk '.$dataUbah->siswa->nama.' berhasil di edit'); return redirect("$this->url")->with('sukses', 'Data Surat Keterangan Mundur untuk '.$dataUbah->siswa->nama.' berhasil di edit');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment