From e25a2ab6ce17a7eb9e314b9f85a98dee9d5f6aed Mon Sep 17 00:00:00 2001 From: Zohaib Hassan Date: Thu, 14 Sep 2023 06:28:33 +0500 Subject: [PATCH] add localization support for error messages add localization support for error messages. now one can set abort message in config to 'common.laratrust.abort' and add its translations to locale files. --- src/Middleware/LaratrustMiddleware.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Middleware/LaratrustMiddleware.php b/src/Middleware/LaratrustMiddleware.php index 105a3b20..2dc939b6 100644 --- a/src/Middleware/LaratrustMiddleware.php +++ b/src/Middleware/LaratrustMiddleware.php @@ -46,12 +46,12 @@ protected function unauthorized(): mixed if ($handling == 'abort') { $defaultMessage = 'User does not have any of the necessary access rights.'; - return App::abort($handler['code'], $handler['message'] ?? $defaultMessage); + return App::abort($handler['code'], __($handler['message']) ?? $defaultMessage); } $redirect = Redirect::to($handler['url']); if (! empty($handler['message']['content'])) { - $redirect->with($handler['message']['key'], $handler['message']['content']); + $redirect->with($handler['message']['key'], __($handler['message']['content'])); } return $redirect;