Files
solidtime/app/Exceptions/Api/EntityStillInUseApiException.php
2026-08-31 11:14:23 +02:00

44 lines
1023 B
PHP

<?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();
$this->modelToDelete = $modelToDelete;
$this->modelInUse = $modelInUse;
}
public const string KEY = 'entity_still_in_use';
/**
* Report the exception.
*
* @return bool true means the exception handler will not report it again
*/
public function report(): bool
{
return true;
}
/**
* 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),
]);
}
}