Skip to content

Commit 89656c7

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 5ff813f + 7f76198 commit 89656c7

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

app/Http/Controllers/Api/LicenseSeatsController.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,14 @@ public function show($licenseId, $seatId) : JsonResponse | array
7979
{
8080

8181
$this->authorize('view', License::class);
82-
// sanity checks:
83-
// 1. does the license seat exist?
84-
if (! $licenseSeat = LicenseSeat::find($seatId)) {
85-
return response()->json(Helper::formatStandardApiResponse('error', null, 'Seat not found'));
86-
}
87-
// 2. does the seat belong to the specified license?
88-
if (! $licenseSeat = $licenseSeat->license()->first() || $licenseSeat->id != intval($licenseId)) {
89-
return response()->json(Helper::formatStandardApiResponse('error', null, 'Seat does not belong to the specified license'));
82+
83+
if ($licenseSeat = LicenseSeat::where('id',$seatId)->where('license_id', $licenseId)->first()) {
84+
return (new LicenseSeatsTransformer)->transformLicenseSeat($licenseSeat);
9085
}
9186

92-
return (new LicenseSeatsTransformer)->transformLicenseSeat($licenseSeat);
87+
return response()->json(Helper::formatStandardApiResponse('error', null, 'Seat ID or license not found or the seat does not belong to this license'));
88+
89+
9390
}
9491

9592
/**

0 commit comments

Comments
 (0)