File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 44
55use Stevebauman \Inventory \Exceptions \InvalidLocationException ;
66use Illuminate \Support \Facades \Lang ;
7+ use Stevebauman \Inventory \Models \Location ;
78
89/**
910 * Trait LocationTrait.
@@ -24,6 +25,18 @@ public function getLocation($location)
2425 {
2526 if ($ this ->isLocation ($ location )) {
2627 return $ location ;
28+ } else if (is_numeric ($ location )) {
29+ try {
30+ $ result = Location::where ('id ' , '= ' , $ location )->first ();
31+
32+ return $ result ;
33+ } catch (\Exception $ e ) {
34+ $ message = Lang::get ('inventory::exceptions.InvalidLocationException ' , [
35+ 'location ' => $ location ,
36+ ]);
37+
38+ throw new InvalidLocationException ($ message );
39+ }
2740 } else {
2841 $ message = Lang::get ('inventory::exceptions.InvalidLocationException ' , [
2942 'location ' => $ location ,
Original file line number Diff line number Diff line change @@ -285,4 +285,16 @@ public function testRollbackStockMovement() {
285285
286286 $ this ->assertEquals ($ initialQuantity , $ stock ->quantity );
287287 }
288+
289+ public function testNumericLocation () {
290+ $ location = $ this ->newLocation ();
291+
292+ $ item = $ this ->newInventory ();
293+
294+ $ item ->createStockOnLocation (42 , $ location ->id , "New stuff " );
295+
296+ $ newQuantity = $ item ->getTotalStock ();
297+
298+ $ this ->assertEquals (42 , $ newQuantity );
299+ }
288300}
You can’t perform that action at this time.
0 commit comments