86 lines
2.0 KiB
PHP
86 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
use App\Models\SatuanBarang;
|
|
|
|
class SatuanController extends Controller
|
|
{
|
|
/**
|
|
* Create a new controller instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->middleware('auth');
|
|
}
|
|
|
|
/**
|
|
* Show the application dashboard.
|
|
*
|
|
* @return \Illuminate\View\View
|
|
*/
|
|
public function index()
|
|
{
|
|
$data['menu'] = 'Manajemen Barang';
|
|
$data['current_page'] = 'Satuan barang';
|
|
$data['satuan_barang'] = SatuanBarang::all();
|
|
return view('admin.satuan_barang.index',$data);
|
|
}
|
|
|
|
public function update_ajax(Request $request){
|
|
|
|
$data_update = array(
|
|
'nama_satuan' => $request->satuan_barang
|
|
|
|
);
|
|
|
|
$id_jenis = $request->id;
|
|
|
|
|
|
$update = DB::table('tbl_satuan')->where('id',$id_jenis)->update($data_update);
|
|
if($update){
|
|
|
|
return redirect('satuan')->with('sukses','Data Satuan Barang Berhasil di update ...');
|
|
}else{
|
|
|
|
return redirect('satuan')->with('error','Data Satuan Barang Gagal di update ....');
|
|
}
|
|
}
|
|
|
|
public function hapus($id_jenis){
|
|
|
|
$hapus = DB::table('tbl_satuan')->where('id',$id_jenis)->delete();
|
|
|
|
if($hapus){
|
|
|
|
return redirect('satuan')->with('sukses','Data Satuan Barang Berhasil di hapus ...');
|
|
}else{
|
|
|
|
return redirect('satuan')->with('error','Data Satuan Barang Gagal di hapus ....');
|
|
}
|
|
}
|
|
|
|
public function store(Request $request){
|
|
|
|
$data = array(
|
|
'nama_satuan' => $request->satuan_barang
|
|
);
|
|
|
|
$insert = DB::table('tbl_satuan')->insert($data);
|
|
|
|
if($insert){
|
|
|
|
return redirect('satuan')->with('sukses', 'Data Satuan Barang Berhasil di tambahkan ..');
|
|
|
|
}else{
|
|
|
|
return redirect('satuan')->with('error', 'Data Satuan Barang Gagal di tambahkan ..');
|
|
}
|
|
}
|
|
|
|
|
|
}
|