BankAccountException.php 510 B

1234567891011121314151617181920
  1. <?php
  2. namespace App\Exceptions;
  3. use Illuminate\Http\JsonResponse;
  4. use Illuminate\Http\Request;
  5. use RuntimeException;
  6. class BankAccountException extends RuntimeException
  7. {
  8. public function __construct(string $messageKey, private readonly int $status = 422)
  9. {
  10. parent::__construct(__("messages.{$messageKey}"));
  11. }
  12. public function render(Request $request): JsonResponse
  13. {
  14. return response()->json(['payload' => null, 'message' => $this->getMessage()], $this->status);
  15. }
  16. }