Short circuit checkout logic to prevent iterating if we're not checking out to an asset

This commit is contained in:
Daniel Meltzer 2020-05-23 11:48:02 -04:00
parent 7a76cb08a0
commit fe74394ae6
No known key found for this signature in database
GPG key ID: 91C5C7B09A5B1CA0

View file

@ -206,9 +206,11 @@ class BulkAssetsController extends Controller
$asset_ids = array_filter($request->get('selected_assets'));
foreach ($asset_ids as $asset_id) {
if ($target->id == $asset_id && request('checkout_to_type') =='asset') {
return redirect()->back()->with('error', 'You cannot check an asset out to itself.');
if(request('checkout_to_type') =='asset') {
foreach ($asset_ids as $asset_id) {
if ($target->id == $asset_id) {
return redirect()->back()->with('error', 'You cannot check an asset out to itself.');
}
}
}
$checkout_at = date("Y-m-d H:i:s");