ProductManageController.php
unknown
php_laravel_blade
2 years ago
893 B
4
Indexable
public function deleteStokAwal(Request $req) { if($req->stok_delete){ $product = Product::where('kode_barang', $req->kode_barang)->first(); $jumlahStok = ($req->stok_besar*$product->pack) + $req->stok_kecil; $product->stok -= $jumlahStok; if($product->stok < 0){ Session::flash('update_failed', 'Stok Kurang Dari 0'); return back(); } $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' => 0, 'jumlah_kecil' => 0 ]); } return back(); }
Editor is loading...