Added a validation to Transformers/LocationsTransformer.php:transformLocations() in case location doesn't have children location (#7640)

This commit is contained in:
Ivan Nieto 2019-12-06 13:42:36 -06:00 committed by snipe
parent 2a6a381bc7
commit 9291e3ada3

View file

@ -24,12 +24,14 @@ class LocationsTransformer
if ($location) { if ($location) {
$children_arr = []; $children_arr = [];
if(!is_null($location->children)){
foreach($location->children as $child) { foreach($location->children as $child) {
$children_arr[] = [ $children_arr[] = [
'id' => (int) $child->id, 'id' => (int) $child->id,
'name' => $child->name 'name' => $child->name
]; ];
} }
}
$array = [ $array = [
'id' => (int) $location->id, 'id' => (int) $location->id,