From 68aeed43bf600934738334cf0aa70d71ca9ec7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Tue, 6 Dec 2022 14:24:38 +0300 Subject: [PATCH] Added delete last category exception class --- .../Settings/LastCategoryDelete.php | 22 +++++++++++++++++++ app/Jobs/Setting/DeleteCategory.php | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 app/Exceptions/Settings/LastCategoryDelete.php diff --git a/app/Exceptions/Settings/LastCategoryDelete.php b/app/Exceptions/Settings/LastCategoryDelete.php new file mode 100644 index 000000000..ff8ea9c22 --- /dev/null +++ b/app/Exceptions/Settings/LastCategoryDelete.php @@ -0,0 +1,22 @@ + Akaunting charecters + 800 => Setting category menu number + 40 => CRUD (last item) + 1 => First authorized exception + + Code: 100000841 + */ + public function __construct(string $message = '', int $code = 100000841, Throwable|null $previous = null) + { + parent::__construct($message, $code, $previous); + } +} diff --git a/app/Jobs/Setting/DeleteCategory.php b/app/Jobs/Setting/DeleteCategory.php index 8bbb5ebae..e0899be40 100644 --- a/app/Jobs/Setting/DeleteCategory.php +++ b/app/Jobs/Setting/DeleteCategory.php @@ -3,6 +3,7 @@ namespace App\Jobs\Setting; use App\Abstracts\Job; +use App\Exceptions\Settings\LastCategoryDelete; use App\Interfaces\Job\ShouldDelete; use App\Models\Setting\Category; @@ -28,7 +29,7 @@ class DeleteCategory extends Job implements ShouldDelete if (Category::where('type', $this->model->type)->count() == 1) { $message = trans('messages.error.last_category', ['type' => strtolower(trans_choice('general.' . $this->model->type . 's', 1))]); - throw new \Exception($message); + throw new LastCategoryDelete($message); } if ($relationships = $this->getRelationships()) {