Added assets endpoint
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
ac96b8d4ae
commit
021c4f2598
1 changed files with 10 additions and 0 deletions
|
@ -232,7 +232,17 @@ class LocationsController extends Controller
|
||||||
return response()->json(Helper::formatStandardApiResponse('error', null, $location->getErrors()));
|
return response()->json(Helper::formatStandardApiResponse('error', null, $location->getErrors()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function assets(Request $request, Location $location) : JsonResponse | array
|
public function assets(Request $request, Location $location) : JsonResponse | array
|
||||||
|
{
|
||||||
|
$this->authorize('view', Asset::class);
|
||||||
|
$this->authorize('view', $location);
|
||||||
|
$assets = Asset::where('location_id', '=', $location->id)->with('model', 'model.category', 'assetstatus', 'location', 'company', 'defaultLoc');
|
||||||
|
$assets = $assets->get();
|
||||||
|
return (new AssetsTransformer)->transformAssets($assets, $assets->count(), $request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assignedAssets(Request $request, Location $location) : JsonResponse | array
|
||||||
{
|
{
|
||||||
$this->authorize('view', Asset::class);
|
$this->authorize('view', Asset::class);
|
||||||
$this->authorize('view', $location);
|
$this->authorize('view', $location);
|
||||||
|
|
Loading…
Add table
Reference in a new issue