mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Fixed 1001 query on license
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
7650628d30
commit
634a4afa75
|
@ -182,7 +182,7 @@ class LicensesController extends Controller
|
||||||
public function show($id) : JsonResponse | array
|
public function show($id) : JsonResponse | array
|
||||||
{
|
{
|
||||||
$this->authorize('view', License::class);
|
$this->authorize('view', License::class);
|
||||||
$license = License::withCount('freeSeats')->findOrFail($id);
|
$license = License::withCount('freeSeats as free_seats_count')->findOrFail($id);
|
||||||
$license = $license->load('assignedusers', 'licenseSeats.user', 'licenseSeats.asset');
|
$license = $license->load('assignedusers', 'licenseSeats.user', 'licenseSeats.asset');
|
||||||
|
|
||||||
return (new LicensesTransformer)->transformLicense($license);
|
return (new LicensesTransformer)->transformLicense($license);
|
||||||
|
|
|
@ -61,7 +61,7 @@ class LicensesTransformer
|
||||||
'checkin' => Gate::allows('checkin', License::class),
|
'checkin' => Gate::allows('checkin', License::class),
|
||||||
'clone' => Gate::allows('create', License::class),
|
'clone' => Gate::allows('create', License::class),
|
||||||
'update' => Gate::allows('update', License::class),
|
'update' => Gate::allows('update', License::class),
|
||||||
'delete' => (Gate::allows('delete', License::class) && ($license->seats == $license->availCount()->count())) ? true : false,
|
'delete' => (Gate::allows('delete', License::class) && ($license->free_seat_count > 0)) ? true : false,
|
||||||
];
|
];
|
||||||
|
|
||||||
$array += $permissions_array;
|
$array += $permissions_array;
|
||||||
|
|
Loading…
Reference in a new issue