Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/SkusController.php
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | class SkusController extends Controller | ||||
/** | /** | ||||
* Display a listing of the sku. | * Display a listing of the sku. | ||||
* | * | ||||
* @return \Illuminate\Http\JsonResponse | * @return \Illuminate\Http\JsonResponse | ||||
*/ | */ | ||||
public function index() | public function index() | ||||
{ | { | ||||
$response = []; | // Note: Order by title for consistent ordering in tests | ||||
$skus = Sku::select()->get(); | $skus = Sku::select()->orderBy('title')->get(); | ||||
// Note: we do not limit the result to active SKUs only. | // Note: we do not limit the result to active SKUs only. | ||||
// It's because we might need users assigned to old SKUs, | // It's because we might need users assigned to old SKUs, | ||||
// we need to display these old SKUs on the entitlements list | // we need to display these old SKUs on the entitlements list | ||||
$response = []; | |||||
foreach ($skus as $sku) { | foreach ($skus as $sku) { | ||||
if ($data = $this->skuElement($sku)) { | if ($data = $this->skuElement($sku)) { | ||||
$response[] = $data; | $response[] = $data; | ||||
} | } | ||||
} | } | ||||
usort($response, function ($a, $b) { | usort($response, function ($a, $b) { | ||||
return ($b['prio'] <=> $a['prio']); | return ($b['prio'] <=> $a['prio']); | ||||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |