From dd2e4065b09cece03aa4daa19e96f0100720e8af Mon Sep 17 00:00:00 2001 From: Sadegh Barzegar Date: Tue, 21 Jun 2022 09:50:38 +0430 Subject: [PATCH] Modified publish path for lang files --- src/PersianValidationServiceProvider.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/PersianValidationServiceProvider.php b/src/PersianValidationServiceProvider.php index f134274..9a9ad1a 100644 --- a/src/PersianValidationServiceProvider.php +++ b/src/PersianValidationServiceProvider.php @@ -42,16 +42,17 @@ class PersianValidationServiceProvider extends ServiceProvider public function boot() { $vendorLangPath = $langLoaderPath = __DIR__.'/../lang/'; + $laravelVersion = explode('.', app()->version()); // In Laravel 9+, lang files are in root path of app. - $baseLangPath = base_path('lang/'); + $langPath = $laravelVersion[0] >= '9' ? base_path('lang/') : resource_path('lang/'); $langFileName = 'persian-validation'; $langNamespace = 'sbpValidation'; // publish language file to resources/lang/{AppLocale}/persian-validation.php - $this->publishes([ $vendorLangPath => $resourceLangPath ]); + $this->publishes([ $vendorLangPath => $langPath ]); - if (count(glob($resourceLangPath . "*/{$langFileName}.php")) !== 0) - $langLoaderPath = $resourceLangPath; + if (count(glob($langPath . "*/{$langFileName}.php")) !== 0) + $langLoaderPath = $langPath; $this->loadTranslationsFrom($langLoaderPath, $langNamespace);