mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-11 17:52:15 +01:00
Added usage check to delete endpoints
This commit is contained in:
committed by
Constantin Graf
parent
40f1159ea5
commit
ad6146c483
33
app/Exceptions/Api/EntityStillInUseApiException.php
Normal file
33
app/Exceptions/Api/EntityStillInUseApiException.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Exceptions\Api;
|
||||
|
||||
class EntityStillInUseApiException extends ApiException
|
||||
{
|
||||
private string $modelToDelete;
|
||||
|
||||
private string $modelInUse;
|
||||
|
||||
public function __construct(string $modelToDelete, string $modelInUse)
|
||||
{
|
||||
parent::__construct('', 0, null);
|
||||
$this->modelToDelete = $modelToDelete;
|
||||
$this->modelInUse = $modelInUse;
|
||||
}
|
||||
|
||||
public const string KEY = 'entity_still_in_use';
|
||||
|
||||
/**
|
||||
* Get the translated message for the exception.
|
||||
*/
|
||||
#[\Override]
|
||||
public function getTranslatedMessage(): string
|
||||
{
|
||||
return __('exceptions.api.'.$this->getKey(), [
|
||||
'modelToDelete' => __('validation.entities.'.$this->modelToDelete),
|
||||
'modelInUse' => __('validation.entities.'.$this->modelInUse),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user