Added delete last category exception class
This commit is contained in:
parent
1d0849ce98
commit
68aeed43bf
22
app/Exceptions/Settings/LastCategoryDelete.php
Normal file
22
app/Exceptions/Settings/LastCategoryDelete.php
Normal 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);
|
||||
}
|
||||
}
|
@ -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()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user