mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Change the flow of the condition using an early return
This commit is contained in:
parent
ae53609b1b
commit
747d6cfdb4
|
@ -235,28 +235,29 @@ class LicensesController extends Controller
|
||||||
{
|
{
|
||||||
$license = License::with('assignedusers')->find($licenseId);
|
$license = License::with('assignedusers')->find($licenseId);
|
||||||
|
|
||||||
if ($license) {
|
if (!$license) {
|
||||||
$users_count = User::where('autoassign_licenses', '1')->count();
|
return redirect()->route('licenses.index')
|
||||||
$total_seats_count = $license->totalSeatsByLicenseID();
|
->with('error', trans('admin/licenses/message.does_not_exist'));
|
||||||
$available_seats_count = $license->availCount()->count();
|
|
||||||
$checkedout_seats_count = ($total_seats_count - $available_seats_count);
|
|
||||||
|
|
||||||
\Log::debug('Total: '.$total_seats_count);
|
|
||||||
\Log::debug('Users: '.$users_count);
|
|
||||||
\Log::debug('Available: '.$available_seats_count);
|
|
||||||
\Log::debug('Checkedout: '.$checkedout_seats_count);
|
|
||||||
|
|
||||||
|
|
||||||
$this->authorize('view', $license);
|
|
||||||
return view('licenses.view', compact('license'))
|
|
||||||
->with('users_count', $users_count)
|
|
||||||
->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')
|
$users_count = User::where('autoassign_licenses', '1')->count();
|
||||||
->with('error', trans('admin/licenses/message.does_not_exist'));
|
$total_seats_count = $license->totalSeatsByLicenseID();
|
||||||
|
$available_seats_count = $license->availCount()->count();
|
||||||
|
$checkedout_seats_count = ($total_seats_count - $available_seats_count);
|
||||||
|
|
||||||
|
\Log::debug('Total: '.$total_seats_count);
|
||||||
|
\Log::debug('Users: '.$users_count);
|
||||||
|
\Log::debug('Available: '.$available_seats_count);
|
||||||
|
\Log::debug('Checkedout: '.$checkedout_seats_count);
|
||||||
|
|
||||||
|
|
||||||
|
$this->authorize('view', $license);
|
||||||
|
return view('licenses.view', compact('license'))
|
||||||
|
->with('users_count', $users_count)
|
||||||
|
->with('total_seats_count', $total_seats_count)
|
||||||
|
->with('available_seats_count', $available_seats_count)
|
||||||
|
->with('checkedout_seats_count', $checkedout_seats_count);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue