Added delete last category exception class

This commit is contained in:
Cüneyt Şentürk 2022-12-06 14:24:38 +03:00
parent 1d0849ce98
commit 68aeed43bf
2 changed files with 24 additions and 1 deletions

View File

@ -0,0 +1,22 @@
<?php
namespace App\Exceptions\Settings;
use Exception;
use Throwable;
class LastCategoryDelete extends Exception
{
/*
100000000 => 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);
}
}

View File

@ -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()) {