mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Merge pull request #13903 from snipe/fixes/redirect_if_category_invalid
Redirect if category is missing or invalid
This commit is contained in:
commit
01740b7969
|
@ -266,6 +266,14 @@ class ConsumablesController extends Controller
|
||||||
\Log::debug('No enough remaining');
|
\Log::debug('No enough remaining');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure there is a valid category
|
||||||
|
if (!$consumable->category){
|
||||||
|
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.invalid_item_category_single', ['type' => trans('general.consumable')])));
|
||||||
|
|
||||||
|
return redirect()->route('consumables.index')->with('error', trans('general.invalid_item_category_single', ['type' => trans('general.consumable')]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Check if the user exists - @TODO: this should probably be handled via validation, not here??
|
// Check if the user exists - @TODO: this should probably be handled via validation, not here??
|
||||||
if (!$user = User::find($request->input('assigned_to'))) {
|
if (!$user = User::find($request->input('assigned_to'))) {
|
||||||
// Return error message
|
// Return error message
|
||||||
|
|
|
@ -34,6 +34,11 @@ class ConsumableCheckoutController extends Controller
|
||||||
return redirect()->route('consumables.index')->with('error', trans('admin/consumables/message.checkout.unavailable'));
|
return redirect()->route('consumables.index')->with('error', trans('admin/consumables/message.checkout.unavailable'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure there is a valid category
|
||||||
|
if (!$consumable->category){
|
||||||
|
return redirect()->route('consumables.index')->with('error', trans('general.invalid_item_category_single', ['type' => trans('general.consumable')]));
|
||||||
|
}
|
||||||
|
|
||||||
$this->authorize('checkout', $consumable);
|
$this->authorize('checkout', $consumable);
|
||||||
|
|
||||||
return view('consumables/checkout', compact('consumable'));
|
return view('consumables/checkout', compact('consumable'));
|
||||||
|
|
|
@ -353,7 +353,8 @@ return [
|
||||||
'synchronize' => 'Synchronize',
|
'synchronize' => 'Synchronize',
|
||||||
'sync_results' => 'Synchronization Results',
|
'sync_results' => 'Synchronization Results',
|
||||||
'license_serial' => 'Serial/Product Key',
|
'license_serial' => 'Serial/Product Key',
|
||||||
'invalid_category' => 'Invalid category',
|
'invalid_category' => 'Invalid or missing category',
|
||||||
|
'invalid_item_category_single' => 'Invalid or missing :type category. Please update the category of this :type to include a valid category before checking out.',
|
||||||
'dashboard_info' => 'This is your dashboard. There are many like it, but this one is yours.',
|
'dashboard_info' => 'This is your dashboard. There are many like it, but this one is yours.',
|
||||||
'60_percent_warning' => '60% Complete (warning)',
|
'60_percent_warning' => '60% Complete (warning)',
|
||||||
'dashboard_empty' => 'It looks like you have not added anything yet, so we do not have anything awesome to display. Get started by adding some assets, accessories, consumables, or licenses now!',
|
'dashboard_empty' => 'It looks like you have not added anything yet, so we do not have anything awesome to display. Get started by adding some assets, accessories, consumables, or licenses now!',
|
||||||
|
|
Loading…
Reference in a new issue