ProductManageController.php
unknown
php_laravel_blade
3 years ago
1.1 kB
7
Indexable
// Stok Awal
public function viewSetStokAwal()
{
$products = Product::all();
return view('manage_product.set_stock', compact('products'));
}
public function setStokAwal(Request $req)
{
if($req->stok){
$product = Product::where('kode_barang', $req->kode_barang)->first();
$jumlahStok = ($req->stok_besar*$product->pack) + $req->stok_kecil;
$product->stok += $jumlahStok;
$product->save();
}
if(DB::table('stok_awal')->where('kode_barang', $req->kode_barang)->first()){
DB::table('stok_awal')->where('kode_barang', $req->kode_barang)
->update([
'jumlah_besar' => $req->stok_besar,
'jumlah_kecil' => $req->stok_kecil
]);
}else{
DB::table('stok_awal')->insert(['kode_barang' => $req->kode_barang,'jumlah_besar' => $req->stok_besar, 'jumlah_kecil' => $req->stok_kecil]);
}
return back();
}Editor is loading...