mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 07:34:06 -08:00
Added counts to location show() API method
This commit is contained in:
parent
89e06054bf
commit
b69b5fdf84
|
@ -106,7 +106,26 @@ class LocationsController extends Controller
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
$this->authorize('view', Location::class);
|
$this->authorize('view', Location::class);
|
||||||
$location = Location::findOrFail($id);
|
$location = Location::with('parent', 'manager', 'childLocations')
|
||||||
|
->select([
|
||||||
|
'locations.id',
|
||||||
|
'locations.name',
|
||||||
|
'locations.address',
|
||||||
|
'locations.address2',
|
||||||
|
'locations.city',
|
||||||
|
'locations.state',
|
||||||
|
'locations.zip',
|
||||||
|
'locations.country',
|
||||||
|
'locations.parent_id',
|
||||||
|
'locations.manager_id',
|
||||||
|
'locations.created_at',
|
||||||
|
'locations.updated_at',
|
||||||
|
'locations.image',
|
||||||
|
'locations.currency'
|
||||||
|
])
|
||||||
|
->withCount('assignedAssets')
|
||||||
|
->withCount('assets')
|
||||||
|
->withCount('users')->findOrFail($id);
|
||||||
return (new LocationsTransformer)->transformLocation($location);
|
return (new LocationsTransformer)->transformLocation($location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue