@@ -24,7 +24,7 @@ public function index(Request $request)
2424 if ($ request ->has ('storage ' )) {
2525 $ query ->where ('storage ' , $ request ->storage );
2626 }
27- $ stocks = $ query ->with (['branch ' , ' ingredient ' , ' utility ' ])->get ();
27+ $ stocks = $ query ->with (['branch ' ])->get ();
2828
2929 return response ()->json ([
3030 'err ' => 0 ,
@@ -40,7 +40,7 @@ public function getStockMutation(Request $request) {
4040 $ end = $ request ->end . ' 23:59:59 ' ;
4141
4242 // 1. Get the relevant stock items
43- $ query = Stock::with ([ ' ingredient ' , ' utility ' ] );
43+ $ query = Stock::query ( );
4444
4545 if ($ branch != 0 ) {
4646 $ query ->where ('branch_id ' , $ branch )->where ('storage ' , $ storage );
@@ -74,16 +74,12 @@ public function getStockMutation(Request $request) {
7474
7575 return [
7676 'item_code ' => $ first ->item_code ,
77- 'item_name ' => $ first ->item_type === 'INGR '
78- ? $ first ->ingredient ->name
79- : $ first ->utility ->name ,
77+ 'item_name ' => $ first ->item_name ,
8078 'opening ' => (float )$ opening ,
8179 'qty_in ' => (float )$ in ,
8280 'qty_out ' => (float )$ out ,
8381 'closing ' => (float )($ opening + $ in - $ out ),
84- 'unit ' => $ first ->item_type === 'INGR '
85- ? $ first ->ingredient ->unit
86- : 'pcs '
82+ 'unit ' => $ first ->unit || 'pcs '
8783 ];
8884 })->values ();
8985
@@ -283,7 +279,7 @@ public function getStockCard(Request $request)
283279
284280 public function kitchenRequest (Request $ request )
285281 {
286- $ request = KitchenRequest::with ('from_branch ' , 'to_branch ' , 'items ' , ' items.ingredient ' , ' items.utility ' )->get ();
282+ $ request = KitchenRequest::with ([ 'from_branch ' , 'to_branch ' , 'items ' ] )->get ();
287283 return response ()->json ([
288284 'err ' => 0 ,
289285 'msg ' => '' ,
0 commit comments