Kode dari ftuntan_main dengan dependensi diperbarui untuk PHP 8.3 (perbaikan insiden 27 Okt 2026). Dump database di database/sql/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
144 lines
4.6 KiB
PHP
144 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\AplikasiIntegrasi;
|
|
use App\Models\Kontak;
|
|
use App\Models\InformasiTerbaru;
|
|
use App\Models\LinkProdi;
|
|
use App\Models\HimpunanMahasiswa;
|
|
use App\Models\ProfilSingkat;
|
|
use App\Models\Staf;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class StafController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
$session_user = Auth::user();
|
|
$stafs = Staf::all();
|
|
|
|
return view('admin.staf.index', compact('stafs', 'session_user'));
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
$request->validate([
|
|
'nama' => 'required',
|
|
'nip' => 'required',
|
|
'pangkat_golongan' => 'required'
|
|
]);
|
|
|
|
Staf::create($request->all());
|
|
|
|
return redirect('/admin/staf')->with('status', 'Data Berhasil Ditambah');
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \App\Models\Staf $staf
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function update(Request $request, Staf $staf)
|
|
{
|
|
$request->validate([
|
|
'nama' => 'required',
|
|
'nip' => 'required',
|
|
'pangkat_golongan' => 'required'
|
|
]);
|
|
|
|
Staf::where('id', $request->id)
|
|
->update([
|
|
'nama' => $request->nama,
|
|
'nip' => $request->nip,
|
|
'pangkat_golongan' => $request->pangkat_golongan
|
|
]);
|
|
|
|
return redirect('/admin/staf')->with('status', 'Data Berhasil Diubah!');
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param \App\Models\Staf $staf
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy(Staf $staf)
|
|
{
|
|
Staf::destroy($staf->id);
|
|
|
|
return redirect('/admin/staf')->with('status', 'Data Berhasil Dihapus!');
|
|
}
|
|
|
|
public function menuStaf()
|
|
{
|
|
$kontak = Kontak::all()->first();
|
|
$himpunanMahasiswaHeaders = HimpunanMahasiswa::where('release_date', '<=', date('Y-m-d'))
|
|
->orderBy('release_date', 'DESC')
|
|
->get();
|
|
|
|
$linkProdis = LinkProdi::where('release_date', '<=', date('Y-m-d'))
|
|
->orderBy('release_date', 'DESC')
|
|
->get();
|
|
$profilSingkat = ProfilSingkat::all()->first();
|
|
|
|
$stafs = Staf::all();
|
|
|
|
$informasiTerbarus = InformasiTerbaru::informasiTerbaru()->take(6)->get();
|
|
$aplikasiIntegrasis = AplikasiIntegrasi::where('release_date', '<=', date('Y-m-d'))
|
|
->orderBy('release_date', 'DESC')
|
|
->take(3)
|
|
->get();
|
|
|
|
return view('portal.staf.index', compact('stafs', 'kontak', 'informasiTerbarus', 'himpunanMahasiswaHeaders', 'aplikasiIntegrasis', 'linkProdis', 'profilSingkat'));
|
|
}
|
|
|
|
public function detailStaf($slug)
|
|
{
|
|
$kontak = Kontak::all()->first();
|
|
$himpunanMahasiswaHeaders = HimpunanMahasiswa::where('release_date', '<=', date('Y-m-d'))
|
|
->orderBy('release_date', 'DESC')
|
|
->get();
|
|
|
|
$linkProdis = LinkProdi::where('release_date', '<=', date('Y-m-d'))
|
|
->orderBy('release_date', 'DESC')
|
|
->get();
|
|
$profilSingkat = ProfilSingkat::all()->first();
|
|
|
|
$stafs = Staf::all();
|
|
|
|
$informasiTerbarus = InformasiTerbaru::informasiTerbaru()->take(6)->get();
|
|
$aplikasiIntegrasis = AplikasiIntegrasi::where('release_date', '<=', date('Y-m-d'))
|
|
->orderBy('release_date', 'DESC')
|
|
->take(3)
|
|
->get();
|
|
|
|
$rawData = file_get_contents(env("APP_KEPEGAWAIAN_URL")."/API/public/getDetailPegawai.php?id=".$slug);
|
|
$decodedData = json_decode($rawData, true);
|
|
|
|
if(isset($decodedData['jenisPegawai']) && $decodedData['jenisPegawai'] == "TENAGA KEPENDIDIKAN"){
|
|
return view('portal.staf.detail', compact('stafs', 'kontak', 'informasiTerbarus', 'himpunanMahasiswaHeaders', 'aplikasiIntegrasis', 'linkProdis', 'profilSingkat', 'decodedData'));
|
|
}else{
|
|
$data['title'] = '404';
|
|
$data['name'] = 'Page not found';
|
|
return response()->view('errors.404',$data,404);
|
|
}
|
|
|
|
return view('portal.staf.detail', compact('stafs', 'kontak', 'informasiTerbarus', 'himpunanMahasiswaHeaders', 'aplikasiIntegrasis', 'linkProdis', 'profilSingkat'));
|
|
}
|
|
}
|