Skip to content

Commit

Permalink
Merge pull request #59 from andes2912/feature/ppdb
Browse files Browse the repository at this point in the history
Berkas Murid
  • Loading branch information
andes2912 authored May 18, 2022
2 parents ce09f17 + 0b163fb commit 298a33c
Show file tree
Hide file tree
Showing 12 changed files with 461 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateBerkasMuridsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('berkas_murids', function (Blueprint $table) {
$table->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');
}
}
14 changes: 14 additions & 0 deletions Modules/PPDB/Entities/BerkasMurid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Modules\PPDB\Entities;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class BerkasMurid extends Model
{
use HasFactory;

protected $table = 'berkas_murids';

}
5 changes: 3 additions & 2 deletions Modules/PPDB/Http/Controllers/DataMuridController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DataMuridController extends Controller
*/
public function index()
{
$murid = User::where('role','Guest')->get();
$murid = User::with('muridDetail')->where('role','Guest')->get();
return view('ppdb::backend.dataMurid.index', compact('murid'));
}

Expand Down Expand Up @@ -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'));

}
Expand Down
106 changes: 95 additions & 11 deletions Modules/PPDB/Http/Controllers/PendaftaranController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'));
Expand All @@ -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) {
Expand Down Expand Up @@ -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');
}
Expand All @@ -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');
Expand Down
66 changes: 66 additions & 0 deletions Modules/PPDB/Http/Requests/BerkasMuridRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace Modules\PPDB\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class berkasMuridRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'kartu_keluarga' => '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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<th>Nama</th>
<th>Email</th>
<th>Status</th>
<th>Role</th>
<th>Hak Akses</th>
<th>Action</th>
</tr>
</thead>
Expand All @@ -61,7 +61,7 @@
<td> {{$key+1}} </td>
<td> {{$murids->name}} </td>
<td> {{$murids->email}} </td>
<td> {{$murids->status}} </td>
<td> {{$murids->muridDetail->proses}} </td>
<td> {{$murids->role}} </td>
<td>
<a href=" {{route('data-murid.show', $murids->id)}} " class="btn btn-success btn-sm">Detail</a>
Expand Down
Loading

0 comments on commit 298a33c

Please sign in to comment.