Skip to content

Fixed #10052 - Added api endpoint for retrieving assets checked out to asset#17835

Merged
snipe merged 11 commits intogrokability:developfrom
marcusmoore:feature/10052-assigned-assets-via-api
Sep 15, 2025
Merged

Fixed #10052 - Added api endpoint for retrieving assets checked out to asset#17835
snipe merged 11 commits intogrokability:developfrom
marcusmoore:feature/10052-assigned-assets-via-api

Conversation

@marcusmoore
Copy link
Copy Markdown
Collaborator

@marcusmoore marcusmoore commented Sep 9, 2025

This PR populates a stubbed out API endpoint, /api/v1/hardware/{asset}/assigned/assets, allowing for retrieving assets assigned to a specific asset.


In the process, I added a new query scope, applyOffsetAndLimit() on the base SnipeModel that allows the following snippet that appears at the end of a lot (most/all?) of our "index" api controller methods:

$total = $query->count();  
  
$offset = ($request->input('offset') > $total) ? $total : app('api_offset_value');  
$limit = app('api_limit_value');  
  
$assets = $query->skip($offset)->take($limit)->get();

to be simplified to:

$total = $query->count();  
  
$assets = $query->applyOffsetAndLimit($total)->get();

Fixes #10052

@marcusmoore marcusmoore marked this pull request as ready for review September 9, 2025 23:16
@marcusmoore marcusmoore requested a review from snipe as a code owner September 9, 2025 23:16
@marcusmoore marcusmoore linked an issue Sep 9, 2025 that may be closed by this pull request
@snipe snipe merged commit 35739c2 into grokability:develop Sep 15, 2025
6 of 7 checks passed
@marcusmoore marcusmoore deleted the feature/10052-assigned-assets-via-api branch September 15, 2025 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API: Get assets assigned to assets

2 participants