Files
solidtime/app/Exceptions/Api/EntityStillInUseApiException.php
2026-09-24 10:45:18 +02:00

46 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Exceptions\Api;
use Override;
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),
]);
}
}