diff --git a/app/Http/Controllers/Api/PredefinedKitsController.php b/app/Http/Controllers/Api/PredefinedKitsController.php index 6cf0f7bca1..97e179ecb3 100644 --- a/app/Http/Controllers/Api/PredefinedKitsController.php +++ b/app/Http/Controllers/Api/PredefinedKitsController.php @@ -55,7 +55,7 @@ class PredefinedKitsController extends Controller $kit->fill($request->all()); if ($kit->save()) { - return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Created was successfull')); // TODO: trans + return response()->json(Helper::formatStandardApiResponse('success', $kit, trans('admin/kits/general.create_success'))); } return response()->json(Helper::formatStandardApiResponse('error', null, $kit->getErrors())); @@ -89,7 +89,7 @@ class PredefinedKitsController extends Controller $kit->fill($request->all()); if ($kit->save()) { - return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Update was successfull')); // TODO: trans + return response()->json(Helper::formatStandardApiResponse('success', $kit, trans('admin/kits/general.update_success'))); // TODO: trans } return response()->json(Helper::formatStandardApiResponse('error', null, $kit->getErrors())); @@ -113,7 +113,7 @@ class PredefinedKitsController extends Controller $kit->accessories()->detach(); $kit->delete(); - return response()->json(Helper::formatStandardApiResponse('success', null, 'Delete was successfull')); // TODO: trans + return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/kits/general.delete_success'))); // TODO: trans } @@ -214,7 +214,7 @@ class PredefinedKitsController extends Controller $kit = PredefinedKit::findOrFail($kit_id); $kit->licenses()->detach($license_id); - return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Delete was successfull')); // TODO: trans + return response()->json(Helper::formatStandardApiResponse('success', $kit, trans('admin/kits/general.delete_success'))); } /** @@ -238,7 +238,7 @@ class PredefinedKitsController extends Controller */ public function storeModel(Request $request, $kit_id) { - //return response()->json(Helper::formatStandardApiResponse('error', 'string11', dd($request))); // TODO: trans + $this->authorize('update', PredefinedKit::class); @@ -256,7 +256,7 @@ class PredefinedKitsController extends Controller } $relation->attach($model_id, ['quantity' => $quantity]); - return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Model added successfull')); // TODO: trans + return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Model added successfull')); } /** @@ -291,7 +291,7 @@ class PredefinedKitsController extends Controller $kit = PredefinedKit::findOrFail($kit_id); $kit->models()->detach($model_id); - return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Delete was successfull')); // TODO: trans + return response()->json(Helper::formatStandardApiResponse('success', $kit, trans('admin/kits/general.model_removed_success'))); } diff --git a/app/Services/PredefinedKitCheckoutService.php b/app/Services/PredefinedKitCheckoutService.php index abc95b31a9..4249e9613b 100644 --- a/app/Services/PredefinedKitCheckoutService.php +++ b/app/Services/PredefinedKitCheckoutService.php @@ -95,7 +95,7 @@ class PredefinedKitCheckoutService } } if ($quantity > 0) { - $errors[] = "Don't have available assets for model " . $model->name . '. Need ' . $model->pivot->quantity . ' assets.'; // TODO: trans + $errors[] = trans('admin/kits/general.none_models', ['model'=> $model->name, 'qty' => $model->pivot->quantity]); } } @@ -111,7 +111,7 @@ class PredefinedKitCheckoutService foreach ($licenses as $license) { $quantity = $license->pivot->quantity; if ($quantity > count($license->freeSeats)) { - $errors[] = "Don't have free seats for license " . $license->name . '. Need ' . $quantity . ' seats.'; // TODO: trans + $errors[] = trans('admin/kits/general.none_licenses', ['license'=> $license->name, 'qty' => $license->pivot->quantity]); } for ($i = 0; $i < $quantity; $i++) { $seats_to_add[] = $license->freeSeats[$i]; @@ -122,11 +122,10 @@ class PredefinedKitCheckoutService protected function getConsumablesToAdd($kit, &$errors) { - // $consumables = $kit->consumables()->withCount('consumableAssignments as consumable_assignments_count')->get(); $consumables = $kit->consumables()->with('users')->get(); foreach ($consumables as $consumable) { if ($consumable->numRemaining() < $consumable->pivot->quantity) { - $errors[] = "Don't have available consumable " . $consumable->name . '. Need ' . $consumable->pivot->quantity; // TODO: trans + $errors[] = trans('admin/kits/general.none_consumables', ['consumable'=> $consumable->name, 'qty' => $consumable->pivot->quantity]); } } return $consumables; @@ -135,9 +134,9 @@ class PredefinedKitCheckoutService protected function getAccessoriesToAdd($kit, &$errors) { $accessories = $kit->accessories()->with('users')->get(); - foreach ($accessories as $accossory) { - if ($accossory->numRemaining() < $accossory->pivot->quantity) { - $errors[] = "Don't have available accossory " . $accossory->name . '. Need ' . $accossory->pivot->quantity; // TODO: trans + foreach ($accessories as $accessory) { + if ($accessory->numRemaining() < $accessory->pivot->quantity) { + $errors[] = trans('admin/kits/general.none_accessory', ['consumable'=> $accessory->name, 'qty' => $accessory->pivot->quantity]); } } return $accessories; diff --git a/resources/lang/en/admin/kits/general.php b/resources/lang/en/admin/kits/general.php new file mode 100644 index 0000000000..030f790677 --- /dev/null +++ b/resources/lang/en/admin/kits/general.php @@ -0,0 +1,16 @@ + 'About Predefined Kits', + 'checkout' => 'Checkout Kit ', + 'create_success' => 'Kit was successfully created.', + 'create' => 'Create Predefined Kit', + 'update' => 'Update Predefined Kit', + 'delete_success' => 'Kit was successfully deleted.', + 'update_success' => 'Kit was successfully updated.', + 'none_models' => 'There are not enough available assets for :model to checkout. :qty are required. ', + 'none_licenses' => 'There are not enough available seats for :license to checkout. :qty are required. ', + 'none_consumables' => 'There are not enough available units of :consumable to checkout. :qty are required. ', + 'none_accessory' => 'There are not enough available units of :accessory to checkout. :qty are required. ', + +); diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index 3c902c24eb..ec823a4877 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -112,6 +112,7 @@ 'asset_maintenances' => 'Asset Maintenances', 'item' => 'Item', 'insufficient_permissions' => 'Insufficient permissions!', + 'kits' => 'Predefined Kits', 'language' => 'Language', 'last' => 'Last', 'last_login' => 'Last Login', diff --git a/resources/views/kits/checkout.blade.php b/resources/views/kits/checkout.blade.php index d9ca25f55f..b8e836778b 100644 --- a/resources/views/kits/checkout.blade.php +++ b/resources/views/kits/checkout.blade.php @@ -2,7 +2,7 @@ {{-- Page title --}} @section('title') - Apply predefined kit{{-- TODO: trans --}} + {{ trans('admin/kits/general.checkout') }} @parent @stop @@ -20,9 +20,6 @@