First Commit
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\MstGolongan;
|
||||
use Illuminate\Http\Request;
|
||||
use Config;
|
||||
|
||||
class MstGolonganController extends Controller
|
||||
{
|
||||
public function __construct(Request $request){
|
||||
$this->siteTitle = "Data Golongan";
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data = MstGolongan::latest()->paginate(10);
|
||||
|
||||
return view('admin.mst_golongan.index',compact('data'))
|
||||
->with('i', (request()->input('page', 1) - 1) * 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$this->setSubtitle("Tambah Data");
|
||||
return view('admin.mst_golongan.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'nama_golongan' => 'required',
|
||||
'nama_pangkat' => 'required',
|
||||
'golongan_besar' => 'required',
|
||||
'alias' => 'required',
|
||||
]);
|
||||
|
||||
$requestAll = $request->all();
|
||||
MstGolongan::create($requestAll);
|
||||
|
||||
return redirect()->route('mst-golongan.index')
|
||||
->with('success','Post created successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\MstGolongan $MstGolongan
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(MstGolongan $MstGolongan)
|
||||
{
|
||||
$this->setSubtitle("Detail Data");
|
||||
return view('admin.mst_golongan.show',compact('MstGolongan'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\MstGolongan $MstGolongan
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(MstGolongan $MstGolongan)
|
||||
{
|
||||
$this->setSubtitle("Ubah Data");
|
||||
return view('admin.mst_golongan.edit',compact('MstGolongan'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\MstGolongan $MstGolongan
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, MstGolongan $MstGolongan)
|
||||
{
|
||||
$request->validate([
|
||||
'nama_golongan' => 'required',
|
||||
'nama_pangkat' => 'required',
|
||||
'golongan_besar' => 'required',
|
||||
'alias' => 'required',
|
||||
]);
|
||||
|
||||
$requestAll = $request->all();
|
||||
$MstGolongan->update($requestAll);
|
||||
|
||||
return redirect()->route('mst-golongan.index')
|
||||
->with('success','Golongan berhasil diubah!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\MstGolongan $MstGolongan
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(MstGolongan $MstGolongan)
|
||||
{
|
||||
$MstGolongan->delete();
|
||||
|
||||
return redirect()->route('mst-golongan.index')
|
||||
->with('success','Golongan berhasil dihapus!');
|
||||
}
|
||||
|
||||
public function golonganList()
|
||||
{
|
||||
$mstGolongan = MstGolongan::select(["id","nama_golongan","nama_pangkat","alias"])->get();
|
||||
return response()->json($mstGolongan);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user