Added usage check to delete endpoints

This commit is contained in:
Constantin Graf
2024-04-18 21:42:29 +02:00
committed by Constantin Graf
parent 40f1159ea5
commit ad6146c483
18 changed files with 326 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Http\Controllers\Api\V1;
use App\Exceptions\Api\EntityStillInUseApiException;
use App\Http\Requests\V1\Tag\TagStoreRequest;
use App\Http\Requests\V1\Tag\TagUpdateRequest;
use App\Http\Resources\V1\Client\ClientCollection;
@@ -83,7 +84,7 @@ class ClientController extends Controller
/**
* Delete client
*
* @throws AuthorizationException
* @throws AuthorizationException|EntityStillInUseApiException
*
* @operationId deleteClient
*/
@@ -91,6 +92,10 @@ class ClientController extends Controller
{
$this->checkPermission($organization, 'clients:delete', $client);
if ($client->projects()->exists()) {
throw new EntityStillInUseApiException('client', 'project');
}
$client->delete();
return response()->json(null, 204);