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