From 15a992365d0f72b1cd60f00bac1e93ac88b459a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Wed, 5 Apr 2023 14:40:51 +0300 Subject: [PATCH] Fixed transfer category delete and changed type issue.. --- app/Jobs/Setting/DeleteCategory.php | 7 +++++++ resources/lang/en-GB/messages.php | 3 ++- resources/views/settings/categories/edit.blade.php | 14 ++++++++------ .../views/settings/categories/index.blade.php | 6 +++++- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app/Jobs/Setting/DeleteCategory.php b/app/Jobs/Setting/DeleteCategory.php index 24e855f33..e8a3be56d 100644 --- a/app/Jobs/Setting/DeleteCategory.php +++ b/app/Jobs/Setting/DeleteCategory.php @@ -31,6 +31,13 @@ class DeleteCategory extends Job implements ShouldDelete */ public function authorize(): void { + // Can not delete transfer category + if ($this->model->isTransferCategory()) { + $message = trans('messages.error.transfer_category', ['type' => $this->model->name]); + + throw new \Exception($message); + } + // Can not delete the last category by type 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))]); diff --git a/resources/lang/en-GB/messages.php b/resources/lang/en-GB/messages.php index 4652bc0cc..c29678f85 100644 --- a/resources/lang/en-GB/messages.php +++ b/resources/lang/en-GB/messages.php @@ -25,7 +25,8 @@ return [ 'not_user_company' => 'Error: You are not allowed to manage this company!', 'customer' => 'Error: User not created! :name already uses this email address.', 'no_file' => 'Error: No file selected!', - 'last_category' => 'Error: Can not delete the last :type category!', + 'last_category' => 'Error: Can not delete the last :type category!', + 'transfer_category' => 'Error: Can not delete the transfer :type category!', 'change_type' => 'Error: Can not change the type because it has :text related!', 'invalid_apikey' => 'Error: The API Key entered is invalid!', 'import_column' => 'Error: :message Column name: :column. Line number: :line.', diff --git a/resources/views/settings/categories/edit.blade.php b/resources/views/settings/categories/edit.blade.php index 9ffc7fc75..f3ad8fefd 100644 --- a/resources/views/settings/categories/edit.blade.php +++ b/resources/views/settings/categories/edit.blade.php @@ -17,21 +17,23 @@ @if ($type_disabled) - + @else + + + + + @endif - - - - - + @if (! $type_disabled) + @endif @can('update-settings-categories') diff --git a/resources/views/settings/categories/index.blade.php b/resources/views/settings/categories/index.blade.php index cc8d40158..c67bcf8ed 100644 --- a/resources/views/settings/categories/index.blade.php +++ b/resources/views/settings/categories/index.blade.php @@ -67,7 +67,11 @@ @foreach($categories as $item) - +