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,11 +24,13 @@ class LocationsTransformer
if ($location) {
$children_arr = [];
foreach($location->children as $child) {
$children_arr[] = [
'id' => (int) $child->id,
'name' => $child->name
];
if(!is_null($location->children)){
foreach($location->children as $child) {
$children_arr[] = [
'id' => (int) $child->id,
'name' => $child->name
];
}
}
$array = [