75 lines
1.9 KiB
PHP
75 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\SettingPengajuan;
|
|
use Illuminate\Http\Request;
|
|
|
|
class SettingPengajuanController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
$dataExists = SettingPengajuan::exists();
|
|
$data = $dataExists ? SettingPengajuan::first() : null;
|
|
|
|
return view('setting-pengajuan', compact('dataExists', 'data'));
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
$request->validate([
|
|
'tglMulai' => 'required',
|
|
'tglSelesai' => 'required',
|
|
'maxPembimbing' => 'required',
|
|
'maxMahasiswa' => 'required',
|
|
]);
|
|
|
|
SettingPengajuan::create($request->all());
|
|
|
|
return redirect('setting-pengajuan')->with('toast_success', 'Pengaturan Pengajuan Berhasil Ditambahkan.');
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*/
|
|
public function show(string $id)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request, $id)
|
|
{
|
|
$request->validate([
|
|
'tglMulai' => 'required',
|
|
'tglSelesai' => 'required',
|
|
'maxPembimbing' => 'required',
|
|
'maxMahasiswa' => 'required',
|
|
]);
|
|
|
|
$setPengajuan = SettingPengajuan::find($id);
|
|
$setPengajuan->update($request->all());
|
|
|
|
return redirect('setting-pengajuan')->with('toast_success', 'Perubahan Berhasil Disimpan.');
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy(string $id)
|
|
{
|
|
$setPengajuan = SettingPengajuan::find($id);
|
|
$setPengajuan->delete();
|
|
|
|
return redirect('setting-pengajuan')->with('toast_success', 'Pengaturan Pengajuan Berhasil Dihapus.');
|
|
}
|
|
}
|