86 lines
3.0 KiB
PHP
86 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Mahasiswa;
|
|
use App\Models\User;
|
|
use Illuminate\Http\Request;
|
|
|
|
class MahasiswaController extends Controller
|
|
{
|
|
|
|
public function index(){
|
|
//Ambil Semua Data Mahasiswa
|
|
$user = Mahasiswa::
|
|
select(
|
|
'mahasiswas.*',
|
|
'user_dosen_dpu.nama_gelar as dosen_dpu_name',
|
|
)
|
|
->join('users as user_dosen_dpu','mahasiswas.dosen_dpu_id','=','user_dosen_dpu.id')
|
|
->get();
|
|
//Ambil Semua Data User Dengan Role Name DOSEN
|
|
$dosen = User::where('user_roles_id','2')
|
|
->select('users.id','nama_gelar')
|
|
->orderBy('users.id')
|
|
->get();
|
|
return view('mahasiswa.index',['title'=> 'Manajemen Mahasiswa | Admin Dashboard','user'=> $user,'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',
|
|
'judul_skripsi_id'=>'required',
|
|
'judul_skripsi_en'=>'required',
|
|
'judul_jurnal'=>'required',
|
|
'judul_artikel'=>'required',
|
|
'bagian'=>'required|numeric',
|
|
'dosen_dpu_id'=>'required|numeric',
|
|
'dosen_dpa_id'=>'required|numeric',
|
|
'dosen_penguji1_id'=>'required|numeric',
|
|
'dosen_penguji2_id'=>'required|numeric',
|
|
],[
|
|
'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',
|
|
'dosen_dpu_id.numeric'=>'Dosen Pembimbing tidak valid, cek kembali Dosen Pembimbing yang dipilih',
|
|
'dosen_dpa_id.numeric'=>'Dosen Pembimbing tidak valid, cek kembali Dosen Pembimbing yang dipilih',
|
|
'dosen_penguji1_id.numeric'=>'Dosen Penguji tidak valid, cek kembali Dosen Penguji yang dipilih',
|
|
'dosen_penguji2_id.numeric'=>'Dosen Penguji tidak valid, cek kembali Dosen Penguji yang dipilih',
|
|
]);
|
|
$user = new Mahasiswa;
|
|
$user->nim = $request->nim;
|
|
$user->nama = $request->nama;
|
|
$user->nomor_hp = $request->nomor_hp;
|
|
$user->email = $request->email;
|
|
$user->bagian = $request->bagian;
|
|
$user->dosen_dpu_id = $request->dosen_dpu_id;
|
|
$user->dosen_dpa_id = $request->dosen_dpa_id;
|
|
$user->dosen_penguji1_id = $request->dosen_penguji1_id;
|
|
$user->dosen_penguji2_id = $request->dosen_penguji2_id;
|
|
$user->judul_seminar_proposal = $request->judul_seminar_proposal;
|
|
$user->judul_skripsi_id = $request->judul_skripsi_id;
|
|
$user->judul_skripsi_en= $request->judul_skripsi_en;
|
|
$user->judul_jurnal = $request->judul_jurnal;
|
|
$user->judul_artikel = $request->judul_artikel;
|
|
|
|
if($user->save()){
|
|
return redirect()->route('mahasiswa.index')->with('success','Data Telah Berhasil Disimpan');
|
|
}
|
|
return back()->withInput();
|
|
}
|
|
|
|
public function update(Request $request){
|
|
//
|
|
}
|
|
|
|
public function destroy(Request $request){
|
|
//
|
|
}
|
|
|
|
}
|