Change the flow of the condition using an early return

This commit is contained in:
Ivan Nieto Vivanco 2023-04-20 10:37:26 -06:00
parent ae53609b1b
commit 747d6cfdb4

View file

@ -235,7 +235,11 @@ class LicensesController extends Controller
{
$license = License::with('assignedusers')->find($licenseId);
if ($license) {
if (!$license) {
return redirect()->route('licenses.index')
->with('error', trans('admin/licenses/message.does_not_exist'));
}
$users_count = User::where('autoassign_licenses', '1')->count();
$total_seats_count = $license->totalSeatsByLicenseID();
$available_seats_count = $license->availCount()->count();
@ -253,10 +257,7 @@ class LicensesController extends Controller
->with('total_seats_count', $total_seats_count)
->with('available_seats_count', $available_seats_count)
->with('checkedout_seats_count', $checkedout_seats_count);
}
return redirect()->route('licenses.index')
->with('error', trans('admin/licenses/message.does_not_exist'));
}