main
Jing Li 2024-04-04 12:17:43 +08:00
parent 04b20257bf
commit 0c90525765
1 changed files with 10 additions and 3 deletions

View File

@ -6,7 +6,9 @@ use App\Traits\CustomActionTrait;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Validation\ValidationException;
use Slowlyo\OwlAdmin\Controllers\AdminController as Controller; use Slowlyo\OwlAdmin\Controllers\AdminController as Controller;
use Slowlyo\OwlAdmin\Exceptions\AdminException;
use Throwable; use Throwable;
/** /**
@ -39,7 +41,7 @@ abstract class AdminController extends Controller
DB::commit(); DB::commit();
} catch (Throwable $th) { } catch (Throwable $th) {
DB::rollBack(); DB::rollBack();
throw $th; throw $this->prepareException($th);
} }
return $this->response()->successMessage(__('admin.save') . __('admin.successfully')); return $this->response()->successMessage(__('admin.save') . __('admin.successfully'));
@ -68,7 +70,7 @@ abstract class AdminController extends Controller
DB::commit(); DB::commit();
} catch (Throwable $th) { } catch (Throwable $th) {
DB::rollBack(); DB::rollBack();
throw $th; throw $this->prepareException($th);
} }
return $this->response()->successMessage(__('admin.save') . __('admin.successfully')); return $this->response()->successMessage(__('admin.save') . __('admin.successfully'));
@ -87,7 +89,7 @@ abstract class AdminController extends Controller
DB::commit(); DB::commit();
} catch (Throwable $th) { } catch (Throwable $th) {
DB::rollBack(); DB::rollBack();
throw $th; throw $this->prepareException($th);
} }
return $this->response()->successMessage(__('admin.delete') . __('admin.successfully')); return $this->response()->successMessage(__('admin.delete') . __('admin.successfully'));
@ -103,4 +105,9 @@ abstract class AdminController extends Controller
return $path; return $path;
} }
protected function prepareException(Throwable $e)
{
return $e;
}
} }