86 lines
2.1 KiB
PHP
86 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\MstKpkd;
|
|
use Illuminate\Http\Request;
|
|
|
|
class MstKpkdController extends Controller
|
|
{
|
|
public function __construct(){
|
|
$this->siteTitle = "Data KPKD";
|
|
parent::__construct();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$data = MstKpkd::latest()->paginate(10);
|
|
|
|
return view('admin.mst_kpkd.index',compact('data'))
|
|
->with('i', (request()->input('page', 1) - 1) * 10);
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
$this->setSubtitle("Tambah Data");
|
|
return view('admin.mst_kpkd.create');
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
$request->validate([
|
|
'nama' => 'required',
|
|
'nip' => 'required',
|
|
'nrk' => 'required',
|
|
]);
|
|
|
|
$requestAll = $request->all();
|
|
MstKpkd::create($requestAll);
|
|
|
|
return redirect()->route('mst-kpkd.index')
|
|
->with('success','Data KPKD berhasil dibuat.');
|
|
}
|
|
|
|
public function show(MstKpkd $mstKpkd)
|
|
{
|
|
$this->setSubtitle("Detail Data");
|
|
return view('admin.mst_kpkd.show',compact('mstKpkd'));
|
|
}
|
|
|
|
public function edit(MstKpkd $mstKpkd)
|
|
{
|
|
$this->setSubtitle("Ubah Data");
|
|
return view('admin.mst_kpkd.edit',compact('mstKpkd'));
|
|
}
|
|
|
|
public function update(Request $request, MstKpkd $mstKpkd)
|
|
{
|
|
$request->validate([
|
|
'nama' => 'required',
|
|
'nip' => 'required',
|
|
'nrk' => 'required',
|
|
]);
|
|
|
|
$requestAll = $request->all();
|
|
$mstKpkd->update($requestAll);
|
|
|
|
return redirect()->route('mst-kpkd.index')
|
|
->with('success','Data KPKD berhasil diubah!');
|
|
}
|
|
|
|
public function destroy(MstKpkd $mstKpkd)
|
|
{
|
|
$mstKpkd->delete();
|
|
|
|
return redirect()->route('mst-kpkd.index')
|
|
->with('success','Data KPKD berhasil dihapus!');
|
|
}
|
|
|
|
public function kpkdList()
|
|
{
|
|
$mstKpkd = MstKpkd::where("status_aktif", 1)->select(["id","nama"])->get();
|
|
return response()->json($mstKpkd);
|
|
}
|
|
}
|