API model updates, as well as general model updates and code fixes.
This commit is contained in:
parent
8dc1f41b73
commit
32a1dc17ed
16 changed files with 162 additions and 272 deletions
|
@ -49,11 +49,12 @@ class LocationController extends BaseController
|
|||
*/
|
||||
public function lists(Request $request)
|
||||
{
|
||||
return Location::select('locations.*', DB::raw('GROUP_CONCAT(nodes.id) as nodes'))
|
||||
->join('nodes', 'locations.id', '=', 'nodes.location')
|
||||
->groupBy('locations.id')
|
||||
->get()->each(function ($location) {
|
||||
$location->nodes = explode(',', $location->nodes);
|
||||
})->all();
|
||||
return Location::with('nodes')->get()->map(function ($item) {
|
||||
$item->nodes->transform(function ($item) {
|
||||
return collect($item)->only(['id', 'name', 'fqdn', 'scheme', 'daemonListen', 'daemonSFTP']);
|
||||
});
|
||||
|
||||
return $item;
|
||||
})->toArray();
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue