Skip to content

A free open source IT asset/license management system

rename all exceptions

spencerrlonggb934f43db0c4
diff --git a/app/Actions/Categories/DestroyCategoryAction.php b/app/Actions/Categories/DestroyCategoryAction.php
index a674970e0d..305f88fc15 100644
--- a/app/Actions/Categories/DestroyCategoryAction.php
+++ b/app/Actions/Categories/DestroyCategoryAction.php
@@ -2,26 +2,24 @@
namespace App\Actions\Categories;
-use App\Exceptions\ModelIsNotDeletable;
-use App\Exceptions\ModelStillHasAccessories;
-use App\Exceptions\ModelStillHasAssetModels;
-use App\Exceptions\ModelStillHasAssets;
-use App\Exceptions\ModelStillHasComponents;
-use App\Exceptions\ModelStillHasConsumables;
-use App\Exceptions\ModelStillHasLicenses;
-use App\Helpers\Helper;
+use App\Exceptions\ItemStillHasAccessories;
+use App\Exceptions\ItemStillHasAssetModels;
+use App\Exceptions\ItemStillHasAssets;
+use App\Exceptions\ItemStillHasComponents;
+use App\Exceptions\ItemStillHasConsumables;
+use App\Exceptions\ItemStillHasLicenses;
use App\Models\Category;
use Illuminate\Support\Facades\Storage;
class DestroyCategoryAction
{
/**
- * @throws ModelStillHasAssets
- * @throws ModelStillHasAssetModels
- * @throws ModelStillHasComponents
- * @throws ModelStillHasAccessories
- * @throws ModelStillHasLicenses
- * @throws ModelStillHasConsumables
+ * @throws ItemStillHasAssets
+ * @throws ItemStillHasAssetModels
+ * @throws ItemStillHasComponents
+ * @throws ItemStillHasAccessories
+ * @throws ItemStillHasLicenses
+ * @throws ItemStillHasConsumables
*/
static function run(Category $category): bool
{
@@ -35,22 +33,22 @@ class DestroyCategoryAction
]);
if ($category->assets_count > 0) {
- throw new ModelStillHasAssets($category);
+ throw new ItemStillHasAssets($category);
}
if ($category->accessories_count > 0) {
- throw new ModelStillHasAccessories($category);
+ throw new ItemStillHasAccessories($category);
}
if ($category->consumables_count > 0) {
- throw new ModelStillHasConsumables($category);
+ throw new ItemStillHasConsumables($category);
}
if ($category->components_count > 0) {
- throw new ModelStillHasComponents($category);
+ throw new ItemStillHasComponents($category);
}
if ($category->licenses_count > 0) {
- throw new ModelStillHasLicenses($category);
+ throw new ItemStillHasLicenses($category);
}
if ($category->models_count > 0) {
- throw new ModelStillHasAssetModels($category);
+ throw new ItemStillHasAssetModels($category);
}
Storage::disk('public')->delete('categories'.'/'.$category->image);
diff --git a/app/Actions/Manufacturers/DeleteManufacturerAction.php b/app/Actions/Manufacturers/DeleteManufacturerAction.php
index e586c166ef..bb17a27367 100644
--- a/app/Actions/Manufacturers/DeleteManufacturerAction.php
+++ b/app/Actions/Manufacturers/DeleteManufacturerAction.php
@@ -2,11 +2,11 @@
namespace App\Actions\Manufacturers;
-use App\Exceptions\ModelStillHasAccessories;
-use App\Exceptions\ModelStillHasAssets;
-use App\Exceptions\ModelStillHasComponents;
-use App\Exceptions\ModelStillHasConsumables;
-use App\Exceptions\ModelStillHasLicenses;
+use App\Exceptions\ItemStillHasAccessories;
+use App\Exceptions\ItemStillHasAssets;
+use App\Exceptions\ItemStillHasComponents;
+use App\Exceptions\ItemStillHasConsumables;
+use App\Exceptions\ItemStillHasLicenses;
use App\Models\Manufacturer;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
@@ -14,11 +14,11 @@ use Illuminate\Support\Facades\Storage;
class DeleteManufacturerAction
{
/**
- * @throws ModelStillHasAssets
- * @throws ModelStillHasComponents
- * @throws ModelStillHasAccessories
- * @throws ModelStillHasLicenses
- * @throws ModelStillHasConsumables
+ * @throws ItemStillHasAssets
+ * @throws ItemStillHasComponents
+ * @throws ItemStillHasAccessories
+ * @throws ItemStillHasLicenses
+ * @throws ItemStillHasConsumables
*/
static function run(Manufacturer $manufacturer): bool
{
@@ -31,19 +31,19 @@ class DeleteManufacturerAction
]);
if ($manufacturer->assets_count > 0) {
- throw new ModelStillHasAssets($manufacturer);
+ throw new ItemStillHasAssets($manufacturer);
}
if ($manufacturer->accessories_count > 0) {
- throw new ModelStillHasAccessories($manufacturer);
+ throw new ItemStillHasAccessories($manufacturer);
}
if ($manufacturer->consumables_count > 0) {
- throw new ModelStillHasConsumables($manufacturer);
+ throw new ItemStillHasConsumables($manufacturer);
}
if ($manufacturer->components_count > 0) {
- throw new ModelStillHasComponents($manufacturer);
+ throw new ItemStillHasComponents($manufacturer);
}
if ($manufacturer->licenses_count > 0) {
- throw new ModelStillHasLicenses($manufacturer);
+ throw new ItemStillHasLicenses($manufacturer);
}
if ($manufacturer->image) {
diff --git a/app/Actions/Suppliers/DestroySupplierAction.php b/app/Actions/Suppliers/DestroySupplierAction.php
index 8a2b412400..bea1757854 100644
--- a/app/Actions/Suppliers/DestroySupplierAction.php
+++ b/app/Actions/Suppliers/DestroySupplierAction.php
@@ -3,18 +3,18 @@
namespace App\Actions\Suppliers;
use App\Models\Supplier;
-use App\Exceptions\ModelStillHasAssets;
-use App\Exceptions\ModelStillHasMaintenances;
-use App\Exceptions\ModelStillHasLicenses;
+use App\Exceptions\ItemStillHasAssets;
+use App\Exceptions\ItemStillHasMaintenances;
+use App\Exceptions\ItemStillHasLicenses;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
class DestroySupplierAction
{
/**
- * @throws ModelStillHasLicenses
- * @throws ModelStillHasAssets
- * @throws ModelStillHasMaintenances
+ * @throws ItemStillHasLicenses
+ * @throws ItemStillHasAssets
+ * @throws ItemStillHasMaintenances
*/
static function run(Supplier $supplier): bool
{
@@ -24,15 +24,15 @@ class DestroySupplierAction
'licenses as licenses_count'
]);
if ($supplier->assets_count > 0) {
- throw new ModelStillHasAssets($supplier);
+ throw new ItemStillHasAssets($supplier);
}
if ($supplier->maintenances_count > 0) {
- throw new ModelStillHasMaintenances($supplier);
+ throw new ItemStillHasMaintenances($supplier);
}
if ($supplier->licenses_count > 0) {
- throw new ModelStillHasLicenses($supplier);
+ throw new ItemStillHasLicenses($supplier);
}
if ($supplier->image) {
diff --git a/app/Exceptions/ModelStillHasComponents.php b/app/Exceptions/ItemStillHasAccessories.php
similarity index 50%
rename from app/Exceptions/ModelStillHasComponents.php
rename to app/Exceptions/ItemStillHasAccessories.php
index 6acafab206..b40551b08b 100644
--- a/app/Exceptions/ModelStillHasComponents.php
+++ b/app/Exceptions/ItemStillHasAccessories.php
@@ -4,7 +4,7 @@ namespace App\Exceptions;
use Exception;
-class ModelStillHasComponents extends ModelStillHasChildren
+class ItemStillHasAccessories extends ItemStillHasChildren
{
//
}
diff --git a/app/Exceptions/ModelStillHasAssetModels.php b/app/Exceptions/ItemStillHasAssetModels.php
similarity index 50%
rename from app/Exceptions/ModelStillHasAssetModels.php
rename to app/Exceptions/ItemStillHasAssetModels.php
index eeebd0225e..ba71399d51 100644
--- a/app/Exceptions/ModelStillHasAssetModels.php
+++ b/app/Exceptions/ItemStillHasAssetModels.php
@@ -4,7 +4,7 @@ namespace App\Exceptions;
use Exception;
-class ModelStillHasAssetModels extends ModelStillHasChildren
+class ItemStillHasAssetModels extends ItemStillHasChildren
{
//
}
diff --git a/app/Exceptions/ItemStillHasAssets.php b/app/Exceptions/ItemStillHasAssets.php
new file mode 100644
index 0000000000..9cb0782445
--- /dev/null
+++ b/app/Exceptions/ItemStillHasAssets.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace App\Exceptions;
+
+use Exception;
+
+class ItemStillHasAssets extends ItemStillHasChildren
+{
+}
diff --git a/app/Exceptions/ModelStillHasChildren.php b/app/Exceptions/ItemStillHasChildren.php
similarity index 81%
rename from app/Exceptions/ModelStillHasChildren.php
rename to app/Exceptions/ItemStillHasChildren.php
index 30d75a3107..e58f3e98fa 100644
--- a/app/Exceptions/ModelStillHasChildren.php
+++ b/app/Exceptions/ItemStillHasChildren.php
@@ -4,7 +4,7 @@ namespace App\Exceptions;
use Exception;
-class ModelStillHasChildren extends Exception
+class ItemStillHasChildren extends Exception
{
//public function __construct($message, $code = 0, Exception $previous = null, $parent, $children)
//{
diff --git a/app/Exceptions/ModelStillHasLicenses.php b/app/Exceptions/ItemStillHasComponents.php
similarity index 51%
rename from app/Exceptions/ModelStillHasLicenses.php
rename to app/Exceptions/ItemStillHasComponents.php
index cdc561c69f..77cfa5a6a0 100644
--- a/app/Exceptions/ModelStillHasLicenses.php
+++ b/app/Exceptions/ItemStillHasComponents.php
@@ -4,7 +4,7 @@ namespace App\Exceptions;
use Exception;
-class ModelStillHasLicenses extends ModelStillHasChildren
+class ItemStillHasComponents extends ItemStillHasChildren
{
//
}
diff --git a/app/Exceptions/ModelStillHasConsumables.php b/app/Exceptions/ItemStillHasConsumables.php
similarity index 50%
rename from app/Exceptions/ModelStillHasConsumables.php
rename to app/Exceptions/ItemStillHasConsumables.php
index 14cee58af4..917d1f62c5 100644
--- a/app/Exceptions/ModelStillHasConsumables.php
+++ b/app/Exceptions/ItemStillHasConsumables.php
@@ -4,7 +4,7 @@ namespace App\Exceptions;
use Exception;
-class ModelStillHasConsumables extends ModelStillHasChildren
+class ItemStillHasConsumables extends ItemStillHasChildren
{
//
}
diff --git a/app/Exceptions/ItemStillHasLicenses.php b/app/Exceptions/ItemStillHasLicenses.php
new file mode 100644
index 0000000000..454460fe76
--- /dev/null
+++ b/app/Exceptions/ItemStillHasLicenses.php
@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Exceptions;
+
+use Exception;
+
+class ItemStillHasLicenses extends ItemStillHasChildren
+{
+ //
+}
diff --git a/app/Exceptions/ItemStillHasMaintenances.php b/app/Exceptions/ItemStillHasMaintenances.php
new file mode 100644
index 0000000000..2cebf71357
--- /dev/null
+++ b/app/Exceptions/ItemStillHasMaintenances.php
@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Exceptions;
+
+use Exception;
+
+class ItemStillHasMaintenances extends ItemStillHasChildren
+{
+ //
+}
diff --git a/app/Exceptions/ModelStillHasAccessories.php b/app/Exceptions/ModelStillHasAccessories.php
deleted file mode 100644
index 38e67181f1..0000000000
--- a/app/Exceptions/ModelStillHasAccessories.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-namespace App\Exceptions;
-
-use Exception;
-
-class ModelStillHasAccessories extends ModelStillHasChildren
-{
- //
-}
diff --git a/app/Exceptions/ModelStillHasAssets.php b/app/Exceptions/ModelStillHasAssets.php
deleted file mode 100644
index 586864ebe7..0000000000
--- a/app/Exceptions/ModelStillHasAssets.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-
-namespace App\Exceptions;
-
-use Exception;
-
-class ModelStillHasAssets extends ModelStillHasChildren
-{
-}
diff --git a/app/Exceptions/ModelStillHasMaintenances.php b/app/Exceptions/ModelStillHasMaintenances.php
deleted file mode 100644
index d268a40baf..0000000000
--- a/app/Exceptions/ModelStillHasMaintenances.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-namespace App\Exceptions;
-
-use Exception;
-
-class ModelStillHasMaintenances extends ModelStillHasChildren
-{
- //
-}
diff --git a/app/Http/Controllers/Api/CategoriesController.php b/app/Http/Controllers/Api/CategoriesController.php
index a8f4b1862f..cb6f2529ad 100644
--- a/app/Http/Controllers/Api/CategoriesController.php
+++ b/app/Http/Controllers/Api/CategoriesController.php
@@ -3,7 +3,7 @@
namespace App\Http\Controllers\Api;
use App\Actions\Categories\DestroyCategoryAction;
-use App\Exceptions\ModelStillHasChildren;
+use App\Exceptions\ItemStillHasChildren;
use App\Helpers\Helper;
use App\Http\Controllers\Controller;
use App\Http\Transformers\CategoriesTransformer;
@@ -216,7 +216,7 @@ class CategoriesController extends Controller
$this->authorize('delete', Category::class);
try {
DestroyCategoryAction::run(category: $category);
- } catch (ModelStillHasChildren $e) {
+ } catch (ItemStillHasChildren $e) {
return response()->json(
Helper::formatStandardApiResponse('error', null, trans('admin/categories/message.assoc_items', ['asset_type' => $category->category_type]))
);
diff --git a/app/Http/Controllers/Api/ManufacturersController.php b/app/Http/Controllers/Api/ManufacturersController.php
index 94298f34f2..c26c360f5d 100644
--- a/app/Http/Controllers/Api/ManufacturersController.php
+++ b/app/Http/Controllers/Api/ManufacturersController.php
@@ -3,12 +3,12 @@
namespace App\Http\Controllers\Api;
use App\Actions\Manufacturers\DeleteManufacturerAction;
-use App\Exceptions\ModelStillHasAccessories;
-use App\Exceptions\ModelStillHasAssets;
-use App\Exceptions\ModelStillHasChildren;
-use App\Exceptions\ModelStillHasComponents;
-use App\Exceptions\ModelStillHasConsumables;
-use App\Exceptions\ModelStillHasLicenses;
+use App\Exceptions\ItemStillHasAccessories;
+use App\Exceptions\ItemStillHasAssets;
+use App\Exceptions\ItemStillHasChildren;
+use App\Exceptions\ItemStillHasComponents;
+use App\Exceptions\ItemStillHasConsumables;
+use App\Exceptions\ItemStillHasLicenses;
use App\Helpers\Helper;
use App\Http\Controllers\Controller;
use App\Http\Transformers\ManufacturersTransformer;
@@ -196,7 +196,7 @@ class ManufacturersController extends Controller
$this->authorize('delete', $manufacturer);
try {
DeleteManufacturerAction::run($manufacturer);
- } catch (ModelStillHasChildren $e) {
+ } catch (ItemStillHasChildren $e) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/manufacturers/message.assoc_users')));
} catch (\Exception $e) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.something_went_wrong')));
diff --git a/app/Http/Controllers/Api/SuppliersController.php b/app/Http/Controllers/Api/SuppliersController.php
index b46bdc442a..5d0b15f874 100644
--- a/app/Http/Controllers/Api/SuppliersController.php
+++ b/app/Http/Controllers/Api/SuppliersController.php
@@ -3,9 +3,9 @@
namespace App\Http\Controllers\Api;
use App\Actions\Suppliers\DestroySupplierAction;
-use App\Exceptions\ModelStillHasMaintenances;
-use App\Exceptions\ModelStillHasAssets;
-use App\Exceptions\ModelStillHasLicenses;
+use App\Exceptions\ItemStillHasMaintenances;
+use App\Exceptions\ItemStillHasAssets;
+use App\Exceptions\ItemStillHasLicenses;
use App\Helpers\Helper;
use App\Http\Controllers\Controller;
use App\Http\Transformers\SelectlistTransformer;
@@ -200,11 +200,11 @@ class SuppliersController extends Controller
$this->authorize('delete', $supplier);
try {
DestroySupplierAction::run(supplier: $supplier);
- } catch (ModelStillHasAssets $e) {
+ } catch (ItemStillHasAssets $e) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/suppliers/message.delete.assoc_assets', ['asset_count' => (int) $supplier->assets_count])));
- } catch (ModelStillHasMaintenances $e) {
+ } catch (ItemStillHasMaintenances $e) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/suppliers/message.delete.assoc_maintenances', ['asset_maintenances_count' => $supplier->asset_maintenances_count])));
- } catch (ModelStillHasLicenses $e) {
+ } catch (ItemStillHasLicenses $e) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/suppliers/message.delete.assoc_licenses', ['licenses_count' => (int) $supplier->licenses_count])));
} catch (\Exception $e) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.something_went_wrong')));
diff --git a/app/Http/Controllers/BulkCategoriesController.php b/app/Http/Controllers/BulkCategoriesController.php
index 3db5ef0de4..f1298c8a22 100644
--- a/app/Http/Controllers/BulkCategoriesController.php
+++ b/app/Http/Controllers/BulkCategoriesController.php
@@ -3,12 +3,12 @@
namespace App\Http\Controllers;
use App\Actions\Categories\DestroyCategoryAction;
-use App\Exceptions\ModelStillHasAccessories;
-use App\Exceptions\ModelStillHasAssetModels;
-use App\Exceptions\ModelStillHasAssets;
-use App\Exceptions\ModelStillHasComponents;
-use App\Exceptions\ModelStillHasConsumables;
-use App\Exceptions\ModelStillHasLicenses;
+use App\Exceptions\ItemStillHasAccessories;
+use App\Exceptions\ItemStillHasAssetModels;
+use App\Exceptions\ItemStillHasAssets;
+use App\Exceptions\ItemStillHasComponents;
+use App\Exceptions\ItemStillHasConsumables;
+use App\Exceptions\ItemStillHasLicenses;
use App\Models\Category;
use Illuminate\Http\Request;
@@ -27,17 +27,17 @@ class BulkCategoriesController extends Controller
}
try {
DestroyCategoryAction::run(category: $category);
- } catch (ModelStillHasAccessories $e) {
+ } catch (ItemStillHasAccessories $e) {
$errors[] = trans('admin/categories/message.delete.bulk_assoc_accessories', ['category_name' => $category->name]);
- } catch (ModelStillHasAssetModels) {
+ } catch (ItemStillHasAssetModels) {
$errors[] = trans('admin/categories/message.delete.bulk_assoc_models', ['category_name' => $category->name]);
- } catch (ModelStillHasAssets) {
+ } catch (ItemStillHasAssets) {
$errors[] = trans('admin/categories/message.delete.bulk_assoc_assets', ['category_name' => $category->name]);
- } catch (ModelStillHasComponents) {
+ } catch (ItemStillHasComponents) {
$errors[] = trans('admin/categories/message.delete.bulk_assoc_components', ['category_name' => $category->name]);
- } catch (ModelStillHasConsumables) {
+ } catch (ItemStillHasConsumables) {
$errors[] = trans('admin/categories/message.delete.bulk_assoc_consumables', ['category_name' => $category->name]);
- } catch (ModelStillHasLicenses) {
+ } catch (ItemStillHasLicenses) {
$errors[] = trans('admin/categories/message.delete.bulk_assoc_licenses', ['category_name' => $category->name]);
} catch (\Exception $e) {
report($e);
diff --git a/app/Http/Controllers/BulkManufacturersController.php b/app/Http/Controllers/BulkManufacturersController.php
index 2a3f418ef1..f497766e5c 100644
--- a/app/Http/Controllers/BulkManufacturersController.php
+++ b/app/Http/Controllers/BulkManufacturersController.php
@@ -3,13 +3,13 @@
namespace App\Http\Controllers;
use App\Actions\Manufacturers\DeleteManufacturerAction;
-use App\Exceptions\ModelStillHasAccessories;
-use App\Exceptions\ModelStillHasAssetModels;
-use App\Exceptions\ModelStillHasAssets;
-use App\Exceptions\ModelStillHasChildren;
-use App\Exceptions\ModelStillHasComponents;
-use App\Exceptions\ModelStillHasConsumables;
-use App\Exceptions\ModelStillHasLicenses;
+use App\Exceptions\ItemStillHasAccessories;
+use App\Exceptions\ItemStillHasAssetModels;
+use App\Exceptions\ItemStillHasAssets;
+use App\Exceptions\ItemStillHasChildren;
+use App\Exceptions\ItemStillHasComponents;
+use App\Exceptions\ItemStillHasConsumables;
+use App\Exceptions\ItemStillHasLicenses;
use App\Models\Manufacturer;
use Illuminate\Http\Request;
@@ -28,15 +28,15 @@ class BulkManufacturersController extends Controller
}
try {
DeleteManufacturerAction::run(manufacturer: $manufacturer);
- } catch (ModelStillHasAssets $e) {
+ } catch (ItemStillHasAssets $e) {
$errors[] = trans('admin/manufacturers/message.delete.bulk_assoc_assets', ['manufacturer_name' => $manufacturer->name]);
- } catch (ModelStillHasAccessories $e) {
+ } catch (ItemStillHasAccessories $e) {
$errors[] = trans('admin/manufacturers/message.delete.bulk_assoc_accessories', ['manufacturer_name' => $manufacturer->name]);
- } catch (ModelStillHasConsumables $e) {
+ } catch (ItemStillHasConsumables $e) {
$errors[] = trans('admin/manufacturers/message.delete.bulk_assoc_consumables', ['manufacturer_name' => $manufacturer->name]);
- } catch (ModelStillHasComponents $e) {
+ } catch (ItemStillHasComponents $e) {
$errors[] = trans('admin/manufacturers/message.delete.bulk_assoc_components', ['manufacturer_name' => $manufacturer->name]);;
- } catch (ModelStillHasLicenses $e) {
+ } catch (ItemStillHasLicenses $e) {
$errors[] = trans('admin/manufacturers/message.delete.bulk_assoc_licenses', ['manufacturer_name' => $manufacturer->name]);;
} catch (\Exception $e) {
report($e);
diff --git a/app/Http/Controllers/BulkSuppliersController.php b/app/Http/Controllers/BulkSuppliersController.php
index ce1a40ac30..c4df351075 100644
--- a/app/Http/Controllers/BulkSuppliersController.php
+++ b/app/Http/Controllers/BulkSuppliersController.php
@@ -3,9 +3,9 @@
namespace App\Http\Controllers;
use App\Actions\Suppliers\DestroySupplierAction;
-use App\Exceptions\ModelStillHasMaintenances;
-use App\Exceptions\ModelStillHasAssets;
-use App\Exceptions\ModelStillHasLicenses;
+use App\Exceptions\ItemStillHasMaintenances;
+use App\Exceptions\ItemStillHasAssets;
+use App\Exceptions\ItemStillHasLicenses;
use App\Models\Supplier;
use Illuminate\Http\Request;
@@ -24,11 +24,11 @@ class BulkSuppliersController extends Controller
}
try {
DestroySupplierAction::run(supplier: $supplier);
- } catch (ModelStillHasAssets $e) {
+ } catch (ItemStillHasAssets $e) {
$errors[] = trans('admin/suppliers/message.delete.bulk_assoc_assets', ['supplier_name' => $supplier->name]);
- } catch (ModelStillHasMaintenances $e) {
+ } catch (ItemStillHasMaintenances $e) {
$errors[] = trans('admin/suppliers/message.delete.bulk_assoc_maintenances', ['supplier_name' => $supplier->name]);;
- } catch (ModelStillHasLicenses $e) {
+ } catch (ItemStillHasLicenses $e) {
$errors[] = trans('admin/suppliers/message.delete.bulk_assoc_licenses', ['supplier_name' => $supplier->name]);
} catch (\Exception $e) {
report($e);
diff --git a/app/Http/Controllers/CategoriesController.php b/app/Http/Controllers/CategoriesController.php
index f627599541..aa75f83d15 100755
--- a/app/Http/Controllers/CategoriesController.php
+++ b/app/Http/Controllers/CategoriesController.php
@@ -3,13 +3,13 @@
namespace App\Http\Controllers;
use App\Actions\Categories\DestroyCategoryAction;
-use App\Exceptions\ModelStillHasAccessories;
-use App\Exceptions\ModelStillHasAssetModels;
-use App\Exceptions\ModelStillHasAssets;
-use App\Exceptions\ModelStillHasChildren;
-use App\Exceptions\ModelStillHasComponents;
-use App\Exceptions\ModelStillHasConsumables;
-use App\Exceptions\ModelStillHasLicenses;
+use App\Exceptions\ItemStillHasAccessories;
+use App\Exceptions\ItemStillHasAssetModels;
+use App\Exceptions\ItemStillHasAssets;
+use App\Exceptions\ItemStillHasChildren;
+use App\Exceptions\ItemStillHasComponents;
+use App\Exceptions\ItemStillHasConsumables;
+use App\Exceptions\ItemStillHasLicenses;
use App\Helpers\Helper;
use App\Http\Requests\ImageUploadRequest;
use App\Models\Category;
@@ -156,7 +156,7 @@ class CategoriesController extends Controller
$this->authorize('delete', Category::class);
try {
DestroyCategoryAction::run($category);
- } catch (ModelStillHasChildren $e) {
+ } catch (ItemStillHasChildren $e) {
return redirect()->route('categories.index')->with('error', trans('admin/categories/message.assoc_items', ['asset_type' => $category->category_type]));
} catch (\Exception $e) {
report($e);
diff --git a/app/Http/Controllers/ManufacturersController.php b/app/Http/Controllers/ManufacturersController.php
index 965f49be30..dbf29c543f 100755
--- a/app/Http/Controllers/ManufacturersController.php
+++ b/app/Http/Controllers/ManufacturersController.php
@@ -3,12 +3,12 @@
namespace App\Http\Controllers;
use App\Actions\Manufacturers\DeleteManufacturerAction;
-use App\Exceptions\ModelStillHasAccessories;
-use App\Exceptions\ModelStillHasAssets;
-use App\Exceptions\ModelStillHasChildren;
-use App\Exceptions\ModelStillHasComponents;
-use App\Exceptions\ModelStillHasConsumables;
-use App\Exceptions\ModelStillHasLicenses;
+use App\Exceptions\ItemStillHasAccessories;
+use App\Exceptions\ItemStillHasAssets;
+use App\Exceptions\ItemStillHasChildren;
+use App\Exceptions\ItemStillHasComponents;
+use App\Exceptions\ItemStillHasConsumables;
+use App\Exceptions\ItemStillHasLicenses;
use App\Helpers\Helper;
use App\Http\Requests\ImageUploadRequest;
use App\Models\Actionlog;
@@ -170,7 +170,7 @@ class ManufacturersController extends Controller
$this->authorize('delete', $manufacturer);
try {
DeleteManufacturerAction::run($manufacturer);
- } catch (ModelStillHasChildren $e) {
+ } catch (ItemStillHasChildren $e) {
return redirect()->route('manufacturers.index')->with('error', trans('admin/manufacturers/message.assoc_users'));
} catch (\Exception $e) {
return redirect()->route('manufacturers.index')->with('error', trans('general.something_went_wrong'));
diff --git a/app/Http/Controllers/SuppliersController.php b/app/Http/Controllers/SuppliersController.php
index cd2d9784ae..34ee3b0e0d 100755
--- a/app/Http/Controllers/SuppliersController.php
+++ b/app/Http/Controllers/SuppliersController.php
@@ -3,13 +3,14 @@
namespace App\Http\Controllers;
use App\Actions\Suppliers\DestroySupplierAction;
-use App\Exceptions\ModelStillHasMaintenances;
-use App\Exceptions\ModelStillHasAssets;
-use App\Exceptions\ModelStillHasLicenses;
+use App\Exceptions\ItemStillHasMaintenances;
+use App\Exceptions\ItemStillHasAssets;
+use App\Exceptions\ItemStillHasLicenses;
use App\Http\Requests\ImageUploadRequest;
use App\Models\Supplier;
use Illuminate\Http\RedirectResponse;
use \Illuminate\Contracts\View\View;
+use Illuminate\Support\MessageBag;
/**
* This controller handles all actions related to Suppliers for
@@ -124,18 +125,23 @@ class SuppliersController extends Controller
*/
public function destroy(Supplier $supplier): RedirectResponse
{
+ $errors = new MessageBag();
$this->authorize('delete', Supplier::class);
try {
DestroySupplierAction::run(supplier: $supplier);
- } catch (ModelStillHasAssets $e) {
- return redirect()->route('suppliers.index')->with('error', trans('admin/suppliers/message.delete.assoc_assets', ['asset_count' => (int) $supplier->assets_count]));
- } catch (ModelStillHasMaintenances $e) {
- return redirect()->route('suppliers.index')->with('error', trans('admin/suppliers/message.delete.assoc_maintenances', ['asset_maintenances_count' => $supplier->asset_maintenances_count]));
- } catch (ModelStillHasLicenses $e) {
- return redirect()->route('suppliers.index')->with('error', trans('admin/suppliers/message.delete.assoc_licenses', ['licenses_count' => (int) $supplier->licenses_count]));
+ } catch (ItemStillHasAssets $e) {
+ $errors->add('error', trans('admin/suppliers/message.delete.assoc_assets', ['asset_count' => (int) $supplier->assets_count]));
+ } catch (ItemStillHasMaintenances $e) {
+ $errors->add('error', trans('admin/suppliers/message.delete.assoc_maintenances', ['asset_maintenances_count' => $supplier->asset_maintenances_count]));
+ } catch (ItemStillHasLicenses $e) {
+ $errors->add('error', trans('admin/suppliers/message.delete.assoc_licenses', ['licenses_count' => (int) $supplier->licenses_count]));
} catch (\Throwable $e) {
report($e);
- return redirect()->route('suppliers.index')->with('error', trans('admin/suppliers/message.delete.error'));
+ $errors->add('error', trans('general.something_went_wrong'));
+ }
+
+ if ($errors->count() > 0) {
+ return redirect()->route('suppliers.index')->with('multi_errors', $errors);
}
return redirect()->route('suppliers.index')->with('success', trans('admin/suppliers/message.delete.success'));