Move a couple assignation of variables inside an else to only execute once

This commit is contained in:
Ivan Nieto Vivanco 2023-08-15 21:10:48 -06:00
parent 993918f47c
commit 92df32dfaa

View file

@ -204,12 +204,9 @@ class ComponentsController extends Controller
$this->authorize('view', \App\Models\Asset::class);
$component = Component::findOrFail($id);
$assets = $component->assets();
$offset = request('offset', 0);
$limit = $request->input('limit', 50);
$total = $assets->count();
$assets = $assets->skip($offset)->take($limit)->get();
if ($request->filled('search')) {
$assets = $component->assets()
@ -224,6 +221,11 @@ class ComponentsController extends Controller
})
->get();
$total = $assets->count();
} else {
$assets = $component->assets();
$total = $assets->count();
$assets = $assets->skip($offset)->take($limit)->get();
}
return (new ComponentsTransformer)->transformCheckedoutComponents($assets, $total);