First Commit
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\MstKeputusan;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MstKeputusanController extends Controller
|
||||
{
|
||||
public function __construct(){
|
||||
$this->siteTitle = "Data Keputusan";
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data = MstKeputusan::latest()->paginate(10);
|
||||
|
||||
return view('admin.mst_keputusan.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_keputusan.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_keputusan' => 'required',
|
||||
]);
|
||||
|
||||
$requestAll = $request->all();
|
||||
MstKeputusan::create($requestAll);
|
||||
|
||||
return redirect()->route('mst-keputusan.index')
|
||||
->with('success','Post created successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\MstKeputusan $mstKeputusan
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(MstKeputusan $mstKeputusan)
|
||||
{
|
||||
// var_dump($mstKeputusan); exit;
|
||||
$this->setSubtitle("Detail Data");
|
||||
return view('admin.mst_keputusan.show',compact('mstKeputusan'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\MstKeputusan $mstKeputusan
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(MstKeputusan $mstKeputusan)
|
||||
{
|
||||
$this->setSubtitle("Ubah Data");
|
||||
return view('admin.mst_keputusan.edit',compact('mstKeputusan'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\MstKeputusan $mstKeputusan
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, MstKeputusan $mstKeputusan)
|
||||
{
|
||||
$request->validate([
|
||||
'nama_keputusan' => 'required',
|
||||
]);
|
||||
|
||||
$requestAll = $request->all();
|
||||
$mstKeputusan->update($requestAll);
|
||||
|
||||
return redirect()->route('mst-keputusan.index')
|
||||
->with('success','Keputusan berhasil diubah!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\MstKeputusan $mstKeputusan
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(MstKeputusan $mstKeputusan)
|
||||
{
|
||||
$mstKeputusan->delete();
|
||||
|
||||
return redirect()->route('mst-keputusan.index')
|
||||
->with('success','Keputusan berhasil dihapus!');
|
||||
}
|
||||
|
||||
public function keputusanList()
|
||||
{
|
||||
$mstKeputusan = MstKeputusan::select(["id","nama_keputusan"])->get();
|
||||
return response()->json($mstKeputusan);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user