efbe
b815d0396f
All checks were successful
Run Action to Production / run pull to sync on target message (push) Has been skipped
93 lines
3.9 KiB
PHP
93 lines
3.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Mahasiswa;
|
|
use App\Models\PengajuanDpuDpa;
|
|
use App\Models\User;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class LayananPengajuanDpuDpaController extends Controller
|
|
{
|
|
|
|
public function index(){
|
|
$data = PengajuanDpuDpa::
|
|
select('pengajuan_dpu_dpas.*',
|
|
'mahasiswas.nim as nim',
|
|
'mahasiswas.nama as nama',
|
|
'dosen_dpu.nama_gelar as dpu_nama_gelar',
|
|
'dosen_dpa.nama_gelar as dpa_nama_gelar'
|
|
)
|
|
->join('mahasiswas','mahasiswas_id','=','mahasiswas.id')
|
|
->join('users as dosen_dpu','mahasiswas.dosen_dpu_id','=','dosen_dpu.id')
|
|
->join('users as dosen_dpa','mahasiswas.dosen_dpa_id','=','dosen_dpa.id')
|
|
->get();
|
|
return view('layanan-dpudpa.index',['title' => 'Pengajuan DPU/DPA | Admin Dashboard','data' => $data]);
|
|
}
|
|
public function tambah(){
|
|
$dosen = User::role('Dosen')->get();
|
|
return view('layanan-dpudpa.tambah',['dosen'=>$dosen]);
|
|
}
|
|
public function store(Request $request){
|
|
|
|
$request->validate([
|
|
'nim'=>'required|numeric',
|
|
'nama'=>'required',
|
|
'nomor_hp'=>'required|numeric',
|
|
'email'=>'required|email',
|
|
'judul_seminar_proposal'=>'required',
|
|
'bagian'=>'required|numeric',
|
|
'dosen_dpu'=>'required|numeric',
|
|
'dosen_dpa'=>'required|numeric',
|
|
'file_transkrip' => 'required|mimes:pdf|max:4096',
|
|
],[
|
|
'nim.required'=>'NIP Wajib Diisi',
|
|
'nim.numeric'=>'NIM Wajib Berisi Angka saja',
|
|
'nomor_hp.numeric'=>'Nomor HP Wajib Menggunakan Angka, Contoh 089xxxxx',
|
|
'email.email'=>'Format email tidak sesuai, cek lagi email anda, Contoh mahasiswa@mail.com/ mahasiswa@mail.unej.ac.id',
|
|
'bagian.numeric'=>'Bagian tidak valid, cek kembali Bagian yang dipilih',
|
|
'dosen_dpu.numeric'=>'Dosen Pembimbing tidak valid, cek kembali Dosen Pembimbing Utama yang dipilih',
|
|
'dosen_dpa.numeric'=>'Dosen Pembimbing tidak valid, cek kembali Dosen Pembimbing Anggota yang dipilih',
|
|
'file_transkrip.mimes'=>'Format File Bukan PDF, Cek Ulang file anda',
|
|
'file_transkrip.max'=>'Ukuran File Anda lebih dari 4Mb, Cek Ulang File anda',
|
|
]);
|
|
|
|
$file_transkrip = $request->file('file_transkrip');
|
|
$file_transkrip_name = 'LS_'.str_replace(' ', '_',$file_transkrip->getClientOriginalName());
|
|
$path = $request->nim.'/'.$file_transkrip_name;
|
|
//jika berhasil save file maka data mhs akan disimpan, dan pengajuan akan diisi
|
|
if(Storage::disk('public')->put($path, file_get_contents($file_transkrip))){
|
|
|
|
$data_mhs['nim'] = $request->nim;
|
|
$data_mhs['nama'] = $request->nama;
|
|
$data_mhs['nomor_hp'] = $request->nomor_hp;
|
|
$data_mhs['email'] = $request->email;
|
|
$data_mhs['judul_seminar_proposal'] = $request->judul_seminar_proposal;
|
|
$data_mhs['bagian'] = $request->bagian;
|
|
$data_mhs['dosen_dpu_id'] = $request->dosen_dpu;
|
|
$data_mhs['dosen_dpa_id'] = $request->dosen_dpa;
|
|
|
|
//set default to -
|
|
$data_mhs['dosen_penguji1_id'] = 1;
|
|
$data_mhs['dosen_penguji2_id'] = 1;
|
|
$data_mhs['judul_skripsi_id'] = '-';
|
|
$data_mhs['judul_skripsi_en'] = '-';
|
|
$data_mhs['judul_jurnal'] = '-';
|
|
$data_mhs['judul_artikel'] = '-';
|
|
|
|
|
|
if(Mahasiswa::create($data_mhs)){
|
|
$mahasiswas_id = Mahasiswa::where('nim',$request->nim)->first();
|
|
$data_dpudpa['mahasiswas_id'] = $mahasiswas_id->id;
|
|
$data_dpudpa['bukti_transkrip_nilai'] = $file_transkrip_name;
|
|
PengajuanDpuDpa::create($data_dpudpa);
|
|
return redirect()->route('layanan-dpudpa.tambah')->with('success','Sukses Tambah Data, Silahkan Menunggu Email Konfirmasi setelah disetujui Oleh Operator');
|
|
}
|
|
return redirect()->route('layanan-dpudpa.tambah')->with('error','Gagal Tambah data, Cek kembali data yang anda masukkan');
|
|
}
|
|
return redirect()->route('layanan-dpudpa.tambah')->with('error','Gagal Tambah data, Cek kembali data yang anda masukkan');
|
|
}
|
|
|
|
}
|