big commit

This commit is contained in:
omair saleh
2021-04-05 11:58:32 +08:00
parent fb5dda8cf9
commit b679ae7f40
49 changed files with 1215 additions and 444 deletions
@@ -3,14 +3,17 @@
namespace App\Classes\General\Abstracts;
use App\Classes\Exceptions\ErrorException;
use App\Classes\Exceptions\InternalServerErrorException;
use App\Classes\ValueObjects\Constants\Notifications;
use App\Classes\ValueObjects\Constants\HttpStatus;
use App\Classes\ValueObjects\Response\ApiResponseObject;
use ErrorException;
use ErrorException as GeneralExceptions;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Facades\DB;
abstract class AbstractControllerLogic
{
@@ -49,10 +52,17 @@ abstract class AbstractControllerLogic
try {
return $this->logic($request);
DB::beginTransaction();
} catch (ErrorException $exception){
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(), $exception->getCode() === 0 ? 500 : $exception->getCode()))->handler();
$response = $this->logic($request);
DB::commit();
return $response;
} catch (ErrorException|GeneralExceptions $exception){
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
$exception->getCode() ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
}
}