mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-10 17:22:15 +01:00
Added usage check to delete endpoints
This commit is contained in:
committed by
Constantin Graf
parent
40f1159ea5
commit
ad6146c483
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user