From 0b163fb37776852ee36fb06592536c29bc136df6 Mon Sep 17 00:00:00 2001 From: andes2912 Date: Wed, 18 May 2022 15:11:51 +0700 Subject: [PATCH] Berkas Murid --- ...4_01_191038_create_berkas_murids_table.php | 40 +++++ Modules/PPDB/Entities/BerkasMurid.php | 14 ++ .../Http/Controllers/DataMuridController.php | 5 +- .../Controllers/PendaftaranController.php | 106 +++++++++++-- .../PPDB/Http/Requests/BerkasMuridRequest.php | 66 ++++++++ .../views/backend/dataMurid/index.blade.php | 4 +- .../views/backend/dataMurid/show.blade.php | 67 ++++++-- .../backend/pendaftaran/berkas.blade.php | 143 ++++++++++++++++++ Modules/PPDB/Routes/web.php | 8 +- app/Models/User.php | 6 + ..._04_01_190600_add_field_to_data_murids.php | 32 ++++ .../views/layouts/backend/style.blade.php | 1 + 12 files changed, 461 insertions(+), 31 deletions(-) create mode 100644 Modules/PPDB/Database/Migrations/2022_04_01_191038_create_berkas_murids_table.php create mode 100644 Modules/PPDB/Entities/BerkasMurid.php create mode 100644 Modules/PPDB/Http/Requests/BerkasMuridRequest.php create mode 100644 Modules/PPDB/Resources/views/backend/pendaftaran/berkas.blade.php create mode 100644 database/migrations/2022_04_01_190600_add_field_to_data_murids.php diff --git a/Modules/PPDB/Database/Migrations/2022_04_01_191038_create_berkas_murids_table.php b/Modules/PPDB/Database/Migrations/2022_04_01_191038_create_berkas_murids_table.php new file mode 100644 index 0000000..212b8e0 --- /dev/null +++ b/Modules/PPDB/Database/Migrations/2022_04_01_191038_create_berkas_murids_table.php @@ -0,0 +1,40 @@ +id(); + $table->bigInteger('user_id'); + $table->string('kartu_keluarga')->nullable(); + $table->string('akte_kelahiran')->nullable(); + $table->string('surat_kelakuan_baik')->nullable(); + $table->string('surat_sehat')->nullable(); + $table->string('surat_tidak_buta_warna')->nullable(); + $table->string('rapor')->nullable(); + $table->string('foto')->nullable(); + $table->string('ijazah')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('berkas_murids'); + } +} diff --git a/Modules/PPDB/Entities/BerkasMurid.php b/Modules/PPDB/Entities/BerkasMurid.php new file mode 100644 index 0000000..9e3e068 --- /dev/null +++ b/Modules/PPDB/Entities/BerkasMurid.php @@ -0,0 +1,14 @@ +get(); + $murid = User::with('muridDetail')->where('role','Guest')->get(); return view('ppdb::backend.dataMurid.index', compact('murid')); } @@ -50,7 +50,8 @@ public function store(Request $request) */ public function show($id) { - $murid = User::with('muridDetail','dataOrtu')->where('role','Guest')->find($id); + $murid = User::with('muridDetail','dataOrtu','berkas')->where('role','Guest')->find($id); + // return $murid; return view('ppdb::backend.dataMurid.show',compact('murid')); } diff --git a/Modules/PPDB/Http/Controllers/PendaftaranController.php b/Modules/PPDB/Http/Controllers/PendaftaranController.php index 1d1ed57..f3a9904 100644 --- a/Modules/PPDB/Http/Controllers/PendaftaranController.php +++ b/Modules/PPDB/Http/Controllers/PendaftaranController.php @@ -4,15 +4,14 @@ use App\Models\dataMurid; use App\Models\User; -use Illuminate\Contracts\Support\Renderable; use ErrorException; use Illuminate\Http\Request; -use Modules\PPDB\Http\Requests\{DataMuridRequest,DataOrtuRequest}; +use Modules\PPDB\Http\Requests\{berkasMuridRequest, DataMuridRequest,DataOrtuRequest}; use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Auth; use DB; +use Modules\PPDB\Entities\BerkasMurid; use Modules\PPDB\Entities\DataOrangTua; -use PhpParser\Node\Stmt\Return_; use Session; class PendaftaranController extends Controller @@ -22,10 +21,9 @@ class PendaftaranController extends Controller public function index() { $user = User::with('muridDetail','dataOrtu')->where('status','Aktif')->where('id',Auth::id())->first(); - + // Jika data murid sudah lengkap if ($user->muridDetail->agama) { - // Session::flash('success','Data kamu sudah lengkap !'); return redirect('ppdb/form-data-orangtua'); } return view('ppdb::backend.pendaftaran.index', compact('user')); @@ -43,13 +41,13 @@ public function update(DataMuridRequest $request, $id) if ($user) { $murid = dataMurid::where('user_id',$id)->first(); - $murid->tempat_lahir = $request->tempat_lahir; + $murid->tempat_lahir = $request->tempat_lahir; $murid->tgl_lahir = $request->tgl_lahir; - $murid->agama = $request->agama; - $murid->telp = $request->telp; + $murid->agama = $request->agama; + $murid->telp = $request->telp; $murid->whatsapp = $request->whatsapp; - $murid->alamat = $request->alamat; - $murid->asal_sekolah = $request->asal_sekolah; + $murid->alamat = $request->alamat; + $murid->asal_sekolah = $request->asal_sekolah; $murid->update(); if ($murid) { @@ -81,7 +79,7 @@ public function dataOrtuView() // jika data orang tua sudah terisi if ($ortu->telp_ayah) { Session::flash('success','Data kamu sudah lengkap !'); - return redirect('/home'); + return redirect('ppdb/form-berkas'); } return view('ppdb::backend.pendaftaran.dataOrtu'); } @@ -107,6 +105,92 @@ public function updateOrtu(DataOrtuRequest $request, $id) $ortu->alamat_ibu = $request->nama_ibu; $ortu->update(); + if ($ortu) { + $berkas = new BerkasMurid(); + $berkas->user_id = $id; + $berkas->save(); + } + + DB::commit(); + Session::flash('success','Success, Data Berhasil dikirim !'); + return redirect('/home'); + } catch (ErrorException $e) { + DB::rollback(); + throw new ErrorException($e->getMessage()); + } + } + + // Berkas View + public function berkasView() + { + $berkas = BerkasMurid::where('user_id', Auth::id())->first(); + // Jika data berkas sudah terisi + if ($berkas->rapor) { + Session::flash('error','Data kamu sudah lengkap !'); + return redirect('/home'); + } + return view('ppdb::backend.pendaftaran.berkas', compact('berkas')); + } + + // Berkas Store + public function berkasStore(berkasMuridRequest $request,$id) + { + try { + DB::beginTransaction(); + $imageKk = $request->file('kartu_keluarga'); + $kartuKeluarga = time()."_".$imageKk->getClientOriginalName(); + // isi dengan nama folder tempat kemana file diupload + $tujuan_upload = 'public/images/berkas_murid'; + $imageKk->storeAs($tujuan_upload,$kartuKeluarga); + + $imageakte = $request->file('kartu_keluarga'); + $akteKelahiran = time()."_".$imageakte->getClientOriginalName(); + // isi dengan nama folder tempat kemana file diupload + $tujuan_upload = 'public/images/berkas_murid'; + $imageakte->storeAs($tujuan_upload,$akteKelahiran); + + $imageskbaik = $request->file('surat_kelakuan_baik'); + $suratbaik = time()."_".$imageskbaik->getClientOriginalName(); + // isi dengan nama folder tempat kemana file diupload + $tujuan_upload = 'public/images/berkas_murid'; + $imageskbaik->storeAs($tujuan_upload,$suratbaik); + + $imagesehat = $request->file('surat_sehat'); + $suratsehat = time()."_".$imagesehat->getClientOriginalName(); + // isi dengan nama folder tempat kemana file diupload + $tujuan_upload = 'public/images/berkas_murid'; + $imagesehat->storeAs($tujuan_upload,$suratsehat); + + $imagemata = $request->file('surat_tidak_buta_warna'); + $surattidakbutawarna = time()."_".$imagemata->getClientOriginalName(); + // isi dengan nama folder tempat kemana file diupload + $tujuan_upload = 'public/images/berkas_murid'; + $imagemata->storeAs($tujuan_upload,$surattidakbutawarna); + + $imagerapor = $request->file('rapor'); + $rapor = time()."_".$imagerapor->getClientOriginalName(); + // isi dengan nama folder tempat kemana file diupload + $tujuan_upload = 'public/images/berkas_murid'; + $imagerapor->storeAs($tujuan_upload,$rapor); + + if ($request->foto) { + $imagefoto = $request->file('foto'); + $foto = time()."_".$imagefoto->getClientOriginalName(); + // isi dengan nama folder tempat kemana file diupload + $tujuan_upload = 'public/images/berkas_murid'; + $imagefoto->storeAs($tujuan_upload,$foto); + } + + $berkas = BerkasMurid::find($id); + $berkas->kartu_keluarga = $kartuKeluarga; + $berkas->akte_kelahiran = $akteKelahiran; + $berkas->surat_kelakuan_baik = $suratbaik; + $berkas->surat_sehat = $suratsehat; + $berkas->surat_tidak_buta_warna = $surattidakbutawarna; + $berkas->rapor = $rapor; + $berkas->foto = $foto ?? NULL; + $berkas->save(); + DB::commit(); Session::flash('success','Success, Data Berhasil dikirim !'); return redirect('/home'); diff --git a/Modules/PPDB/Http/Requests/BerkasMuridRequest.php b/Modules/PPDB/Http/Requests/BerkasMuridRequest.php new file mode 100644 index 0000000..390720e --- /dev/null +++ b/Modules/PPDB/Http/Requests/BerkasMuridRequest.php @@ -0,0 +1,66 @@ + 'required|mimes:jpg,jpeg,png,pdf|max:2048', + 'akte_kelahiran' => 'required|mimes:jpg,jpeg,png,pdf|max:2048', + 'surat_kelakuan_baik' => 'required|mimes:jpg,jpeg,png,pdf|max:2048', + 'surat_sehat' => 'required|mimes:jpg,jpeg,png,pdf|max:2048', + 'surat_tidak_buta_warna' => 'required|mimes:jpg,jpeg,png,pdf|max:2048', + 'rapor' => 'required|mimes:jpg,jpeg,png,pdf|max:2048', + 'foto' => 'required|mimes:jpg,jpeg,png,pdf|max:2048', + 'ijazah' => 'mimes:jpg,jpeg,png,pdf|max:2048' + ]; + } + + public function messages() + { + return [ + 'kartu_keluarga.required' => 'File Kartu Keluarga tidak boleh kosong.', + 'kartu_keluarga.mimes' => 'Kartu Keluarga hanya mendukung .jpg .jpeg .png atau pdf.', + 'kartu_keluarga.max' => 'Ukuran file tidak boleh lebih dari 2MB.', + 'akte_kelahiran.required' => 'File Akte Kelahiran tidak boleh kosong.', + 'akte_kelahiran.mimes' => 'Akte Kelahiran hanya mendukung .jpg .jpeg .png atau pdf.', + 'akte_kelahiran.max' => 'Ukuran file tidak boleh lebih dari 2MB.', + 'surat_kelakuan_baik.required' => 'Surat Kelakuan Baik tidak boleh kosong.', + 'surat_kelakuan_baik.mimes' => 'Surat Kelakuan Baik hanya mendukung .jpg .jpeg .png atau pdf.', + 'surat_kelakuan_baik.max' => 'Ukuran file tidak boleh lebih dari 2MB.', + 'surat_sehat.required' => 'Surat Sehat tidak boleh kosong.', + 'surat_sehat.mimes' => 'Surat Sehat hanya mendukung .jpg .jpeg .png atau pdf.', + 'surat_sehat.max' => 'Ukuran file tidak boleh lebih dari 2MB.', + 'surat_tidak_buta_warna.required' => 'Surat Tidak Buta Warna tidak boleh kosong.', + 'surat_tidak_buta_warna.mimes' => 'Surat Tidak Buta Warna hanya mendukung .jpg .jpeg .png atau pdf.', + 'surat_tidak_buta_warna.max' => 'Ukuran file tidak boleh lebih dari 2MB.', + 'rapor.required' => 'Rapor tidak boleh kosong.', + 'rapor.mimes' => 'Rapor hanya mendukung .jpg .jpeg .png atau pdf.', + 'rapor.max' => 'Ukuran file tidak boleh lebih dari 2MB.', + 'foto.required' => 'Foto tidak boleh kosong.', + 'foto.mimes' => 'Foto hanya mendukung .jpg .jpeg .png atau pdf.', + 'foto.max' => 'Ukuran file tidak boleh lebih dari 2MB.', + + + ]; + } + + /** + * Determine if the user is authorized to make this request. + * + * @return bool + */ + public function authorize() + { + return true; + } +} diff --git a/Modules/PPDB/Resources/views/backend/dataMurid/index.blade.php b/Modules/PPDB/Resources/views/backend/dataMurid/index.blade.php index 89278eb..7954dde 100644 --- a/Modules/PPDB/Resources/views/backend/dataMurid/index.blade.php +++ b/Modules/PPDB/Resources/views/backend/dataMurid/index.blade.php @@ -50,7 +50,7 @@ Nama Email Status - Role + Hak Akses Action @@ -61,7 +61,7 @@ {{$key+1}} {{$murids->name}} {{$murids->email}} - {{$murids->status}} + {{$murids->muridDetail->proses}} {{$murids->role}} Detail diff --git a/Modules/PPDB/Resources/views/backend/dataMurid/show.blade.php b/Modules/PPDB/Resources/views/backend/dataMurid/show.blade.php index 820f4c8..b78efec 100644 --- a/Modules/PPDB/Resources/views/backend/dataMurid/show.blade.php +++ b/Modules/PPDB/Resources/views/backend/dataMurid/show.blade.php @@ -5,6 +5,11 @@ @endsection @section('content') +
@@ -28,7 +33,7 @@
- + @error('name')
{{ $message }} @@ -39,7 +44,7 @@
- + @error('email')
{{ $message }} @@ -50,7 +55,7 @@
- + @error('nis')
{{ $message }} @@ -62,7 +67,7 @@
- + @error('nisn')
{{ $message }} @@ -74,7 +79,7 @@
- + @error('tempat_lahir')
{{ $message }} @@ -86,7 +91,7 @@
- + @error('tgl_lahir')
{{ $message }} @@ -98,7 +103,7 @@
- + @error('telp')
{{ $message }} @@ -110,7 +115,7 @@
- + @error('whatsapp')
{{ $message }} @@ -142,7 +147,7 @@
- + @error('asal_sekolah')
{{ $message }} @@ -169,7 +174,7 @@
- + @error('nama_ayah')
{{ $message }} @@ -180,7 +185,7 @@
- + @error('telp_ayah')
{{ $message }} @@ -243,7 +248,7 @@
- + @error('nama_ibu')
{{ $message }} @@ -254,7 +259,7 @@
- + @error('telp_ibu')
{{ $message }} @@ -310,9 +315,43 @@ @enderror
+

+

Berkas Murid

+
+
+
+
    +
  • Kartu Keluarga + view +
  • +
  • Surat Kelakuan Baik + view +
  • +
  • Surat Tidak Buta Warna + view +
  • +
  • ijazah + view +
  • +
+
+
+
    +
  • Akte Kelahiran + view +
  • +
  • Surat Sehat + view +
  • +
  • Rapor + view +
  • +
+ +
- Batal + Batal
diff --git a/Modules/PPDB/Resources/views/backend/pendaftaran/berkas.blade.php b/Modules/PPDB/Resources/views/backend/pendaftaran/berkas.blade.php new file mode 100644 index 0000000..6dd4eea --- /dev/null +++ b/Modules/PPDB/Resources/views/backend/pendaftaran/berkas.blade.php @@ -0,0 +1,143 @@ +@extends('layouts.backend.app') + +@section('title') + Form Pendaftaran +@endsection + +@section('content') +
+
+
+ +
+
+
+
+
+
+
+

Berkas Pendaftaran

+
+
+
+ @csrf + @method('PUT') +
+
+
+ + + @error('kartu_keluarga') +
+ {{ $message }} +
+ @enderror +
+
+ +
+
+ + + @error('akte_kelahiran') +
+ {{ $message }} +
+ @enderror +
+
+ +
+
+ + + Surat Kelakuan Baik dari sekolah asal. + @error('surat_kelakuan_baik') +
+ {{ $message }} +
+ @enderror +
+
+ +
+
+ + + Surat Sehat dari RS/Puskesmas atau Klinik. + @error('surat_sehat') +
+ {{ $message }} +
+ @enderror +
+
+ +
+
+ + + Surat Tidak Buta Warna dari RS/Puskesmas atau Klinik. + @error('surat_tidak_buta_warna') +
+ {{ $message }} +
+ @enderror +
+
+ +
+
+ + + Rapor Semester 1-4, harap satukan pada 1 file .pdf. + @error('rapor') +
+ {{ $message }} +
+ @enderror +
+
+ +
+
+ + + Pas Foto ukuran 3x4 dengan latar belakang merah dan memakai baju sekolah. + @error('foto') +
+ {{ $message }} +
+ @enderror +
+
+ +
+
+ + + Dapat menyusul. + @error('ijazah') +
+ {{ $message }} +
+ @enderror +
+
+ +
+ + Batal +
+
+
+
+
+ +
+
+@endsection \ No newline at end of file diff --git a/Modules/PPDB/Routes/web.php b/Modules/PPDB/Routes/web.php index fcff820..d76cd08 100644 --- a/Modules/PPDB/Routes/web.php +++ b/Modules/PPDB/Routes/web.php @@ -23,14 +23,18 @@ //// ROLE GUEST \\\\ Route::prefix('/ppdb')->middleware('role:Guest')->group( function (){ - /// DATA MURID \\ + /// DATA MURID \\\ Route::get('form-pendaftaran','PendaftaranController@index')->name('ppdb.form-pendaftaran'); Route::put('form-pendaftaran/{id}','PendaftaranController@update'); - /// DATA ORANG TUA \\ + /// DATA ORANG TUA \\\ Route::get('form-data-orangtua','PendaftaranController@dataOrtuView'); Route::put('form-data-orangtua/{id}','PendaftaranController@updateOrtu'); + + /// BERKAS MURID \\\ + Route::get('form-berkas','PendaftaranController@berkasView'); + Route::put('form-berkas/{id}','PendaftaranController@berkasStore'); }); diff --git a/app/Models/User.php b/app/Models/User.php index ad7d175..39d07ce 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; +use Modules\PPDB\Entities\BerkasMurid; use Modules\PPDB\Entities\DataOrangTua; use Spatie\Permission\Traits\HasRoles; @@ -61,4 +62,9 @@ public function dataOrtu() { return $this->belongsTo(DataOrangTua::class,'id','user_id'); } + + public function berkas() + { + return $this->belongsTo(BerkasMurid::class,'id','user_id'); + } } diff --git a/database/migrations/2022_04_01_190600_add_field_to_data_murids.php b/database/migrations/2022_04_01_190600_add_field_to_data_murids.php new file mode 100644 index 0000000..94b931d --- /dev/null +++ b/database/migrations/2022_04_01_190600_add_field_to_data_murids.php @@ -0,0 +1,32 @@ +enum('proses',['Pendaftaran','Berkas','Murid','Ditolak'])->after('asal_sekolah')->default('Pendaftaran'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('data_murids', function (Blueprint $table) { + // + }); + } +} diff --git a/resources/views/layouts/backend/style.blade.php b/resources/views/layouts/backend/style.blade.php index 7c806d6..66c74aa 100644 --- a/resources/views/layouts/backend/style.blade.php +++ b/resources/views/layouts/backend/style.blade.php @@ -16,6 +16,7 @@ +