mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-24 04:03:34 -08:00
Remove old redundant code in LicensesController, added an offset to AccessoriesController for pagination to work correctly (#6847)
This commit is contained in:
parent
b779e274cc
commit
b1f96448af
|
@ -141,18 +141,27 @@ class AccessoriesController extends Controller
|
|||
return ['total' => 0, 'rows' => []];
|
||||
}
|
||||
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
|
||||
$accessory->lastCheckoutArray = $accessory->lastCheckout->toArray();
|
||||
$accessory_users = $accessory->users;
|
||||
|
||||
$total = $accessory_users->count();
|
||||
|
||||
if($total < $offset){
|
||||
$offset = 0;
|
||||
}
|
||||
|
||||
$accessory_users = $accessory->users()->skip($offset)->take($limit)->get();
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$accessory_users = $accessory->users()
|
||||
->where('first_name', 'like', '%'.$request->input('search').'%')
|
||||
->orWhere('last_name', 'like', '%'.$request->input('search').'%')
|
||||
->get();
|
||||
$total = $accessory_users->count();
|
||||
}
|
||||
|
||||
$total = $accessory_users->count();
|
||||
|
||||
|
||||
return (new AccessoriesTransformer)->transformCheckedoutAccessory($accessory, $accessory_users, $total);
|
||||
}
|
||||
|
||||
|
|
|
@ -231,10 +231,6 @@ class LicensesController extends Controller
|
|||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
|
||||
if($seats->count() < $offset){
|
||||
$offset = 0;
|
||||
}
|
||||
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
$total = $seats->count();
|
||||
|
||||
|
|
Loading…
Reference in a new issue