Implemented Event Budget
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Budget\Controllers;
|
||||
|
||||
use App\Domains\Budget\Actions\CreateEstimate\CreateEstimateAction;
|
||||
use App\Domains\Budget\Actions\CreateEstimate\CreateEstimateRequest;
|
||||
use App\Domains\Budget\Actions\DeleteEstimate\DeleteEstimateAction;
|
||||
use App\Domains\Budget\Actions\DeleteEstimate\DeleteEstimateRequest;
|
||||
use App\Domains\CostUnit\Actions\CreateCostUnit\CreateCostUnitRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use App\ValueObjects\Amount;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteController extends CommonController
|
||||
{
|
||||
public function __invoke(int $costUnitId, int $estimateId, Request $request) : JsonResponse {
|
||||
$estimate = $this->estimates->getById($estimateId);
|
||||
|
||||
if ($estimate === null) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Estimate not found'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$deleteEstimateResponse =
|
||||
new DeleteEstimateAction(request: new DeleteEstimateRequest($estimate)
|
||||
)->execute();
|
||||
|
||||
if ($deleteEstimateResponse->success) {
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Der Eintrag wurde erfolgreich gelöscht.'
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Beim Löschen des Eintrags ist ein Fehler aufgetreten.'
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user