-Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
+---
-- [Simple, fast routing engine](https://laravel.com/docs/routing).
-- [Powerful dependency injection container](https://laravel.com/docs/container).
-- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
-- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
-- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
-- [Robust background job processing](https://laravel.com/docs/queues).
-- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
+# Laravel Vuexy Admin para México
-Laravel is accessible, powerful, and provides tools required for large, robust applications.
+**Laravel Vuexy Admin para México** es un proyecto basado en Laravel optimizado para necesidades específicas del mercado mexicano. Incluye integración con los catálogos del SAT (CFDI 4.0), herramientas avanzadas y una interfaz moderna inspirada en el template premium Vuexy.
-## Learning Laravel
+## Características destacadas
-Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
+- **Optimización para México**:
+ - Uso de los catálogos oficiales del SAT (versión CFDI 4.0):
+ - Banco (`sat_banco`)
+ - Clave de Producto o Servicio (`sat_clave_prod_serv`)
+ - Clave de Unidad (`sat_clave_unidad`)
+ - Forma de Pago (`sat_forma_pago`)
+ - Moneda (`sat_moneda`)
+ - Código Postal (`sat_codigo_postal`)
+ - Régimen Fiscal (`sat_regimen_fiscal`)
+ - País (`sat_pais`)
+ - Uso CFDI (`sat_uso_cfdi`)
+ - Colonia (`sat_colonia`)
+ - Estado (`sat_estado`)
+ - Localidad (`sat_localidad`)
+ - Municipio (`sat_municipio`)
+ - Deducción (`sat_deduccion`)
+ - Percepción (`sat_percepcion`)
+ - Compatible con los lineamientos y formatos del Anexo 20 del SAT.
+ - Útil para generar comprobantes fiscales digitales (CFDI) y otros procesos administrativos locales.
-You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
+- **Otras características avanzadas**:
+ - Autenticación y gestión de usuarios con Laravel Fortify.
+ - Gestión de roles y permisos usando Spatie Permission.
+ - Tablas dinámicas con Laravel Datatables y Yajra.
+ - Integración con Redis para caching eficiente.
+ - Exportación y manejo de Excel mediante Maatwebsite.
-If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
+## Requisitos del Sistema
-## Laravel Sponsors
+- **PHP**: >= 8.2
+- **Composer**: >= 2.0
+- **Node.js**: >= 16.x
+- **MySQL** o cualquier base de datos compatible con Laravel.
-We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
+---
-### Premium Partners
+## Instalación
-- **[Vehikl](https://vehikl.com/)**
-- **[Tighten Co.](https://tighten.co)**
-- **[WebReinvent](https://webreinvent.com/)**
-- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
-- **[64 Robots](https://64robots.com)**
-- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
-- **[Cyber-Duck](https://cyber-duck.co.uk)**
-- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
-- **[Jump24](https://jump24.co.uk)**
-- **[Redberry](https://redberry.international/laravel/)**
-- **[Active Logic](https://activelogic.com)**
-- **[byte5](https://byte5.de)**
-- **[OP.GG](https://op.gg)**
+Este proyecto ofrece dos métodos de instalación: mediante Composer o manualmente. A continuación, te explicamos ambos procesos.
-## Contributing
+### Opción 1: Usar Composer (Recomendado)
-Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
+Para instalar el proyecto rápidamente usando Composer, ejecuta el siguiente comando:
-## Code of Conduct
+```bash
+composer create-project koneko/laravel-vuexy-admin
+```
-In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
+Este comando realizará automáticamente los siguientes pasos:
+1. Configurará el archivo `.env` basado en `.env.example`.
+2. Generará la clave de la aplicación.
-## Security Vulnerabilities
+Una vez completado, debes configurar una base de datos válida en el archivo `.env` y luego ejecutar:
-If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
+```bash
+php artisan migrate --seed
+```
-## License
+Finalmente, compila los activos iniciales:
+
+```bash
+npm install
+npm run dev
+```
+
+Inicia el servidor local con:
+
+```bash
+php artisan serve
+```
+
+---
+
+### Opción 2: Instalación manual
+
+Si prefieres instalar el proyecto de forma manual, sigue estos pasos:
+
+1. Clona el repositorio:
+ ```bash
+ git clone https://git.koneko.mx/Koneko-ST/laravel-vuexy-admin.git
+ cd laravel-vuexy-admin
+ ```
+
+2. Instala las dependencias de Composer:
+ ```bash
+ composer install
+ ```
+
+3. Instala las dependencias de npm:
+ ```bash
+ npm install
+ ```
+
+4. Configura las variables de entorno:
+ ```bash
+ cp .env.example .env
+ ```
+
+5. Configura una base de datos válida en el archivo `.env`.
+
+6. Genera la clave de la aplicación:
+ ```bash
+ php artisan key:generate
+ ```
+
+7. Migra y llena la base de datos:
+ ```bash
+ php artisan migrate --seed
+ ```
+
+8. Compila los activos frontend:
+ ```bash
+ npm run dev
+ ```
+
+9. Inicia el servidor de desarrollo:
+ ```bash
+ php artisan serve
+ ```
+
+---
+
+## Notas importantes
+
+- Asegúrate de tener instalado:
+ - **PHP**: >= 8.2
+ - **Composer**: >= 2.0
+ - **Node.js**: >= 16.x
+- Este proyecto utiliza los catálogos SAT de la versión CFDI 4.0. Si deseas más información, visita la documentación oficial del SAT en [Anexo 20](http://omawww.sat.gob.mx/tramitesyservicios/Paginas/anexo_20.htm).
+
+---
+
+## Uso del Template Vuexy
+
+Este proyecto está diseñado para funcionar con el template premium [Vuexy](https://themeforest.net/item/vuexy-vuejs-html-laravel-admin-dashboard-template/23328599). Para utilizarlo:
+
+1. Adquiere una licencia válida de Vuexy en [ThemeForest](https://themeforest.net/item/vuexy-vuejs-html-laravel-admin-dashboard-template/23328599).
+2. Incluye los archivos necesarios en las carpetas correspondientes (`resources`, `public`, etc.) de este proyecto.
+
+---
+
+## Créditos
+
+Este proyecto utiliza herramientas y recursos de código abierto, así como un template premium. Queremos agradecer a los desarrolladores y diseñadores que hacen posible esta implementación:
+
+- [Laravel](https://laravel.com)
+- [Vuexy Template](https://themeforest.net/item/vuexy-vuejs-html-laravel-admin-dashboard-template/23328599)
+- [Spatie Permission](https://spatie.be/docs/laravel-permission)
+- [Yajra Datatables](https://yajrabox.com/docs/laravel-datatables)
+
+---
+
+## Licencia
+
+Este proyecto está licenciado bajo la licencia MIT. Consulta el archivo [LICENSE](LICENSE) para más detalles.
+
+El template "Vuexy" debe adquirirse por separado y está sujeto a su propia licencia comercial.
+
+---
+
+
-The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
diff --git a/app/Services/WebsiteTemplateService.php b/app/Services/WebsiteTemplateService.php
index 5644ad1..be2bf39 100644
--- a/app/Services/WebsiteTemplateService.php
+++ b/app/Services/WebsiteTemplateService.php
@@ -3,6 +3,7 @@
namespace App\Services;
use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\Schema;
use Modules\Admin\App\Models\Setting;
class WebsiteTemplateService
@@ -25,9 +26,14 @@ class WebsiteTemplateService
/**
* Obtiene las variables del sitio web desde el caché o la base de datos.
*/
- public function getWebsiteVars(String $setting = ''): array
+ public function getWebsiteVars(string $setting = ''): array
{
try {
+ // Verifica si la base de datos está inicializada
+ if (!Schema::hasTable('migrations')) {
+ return $this->getDefaultWebsiteVars($setting);
+ }
+
$webVars = Cache::remember('website_settings', $this->cacheTTL, function () {
$settings = Setting::global()
->where(function ($query) {
@@ -38,31 +44,58 @@ class WebsiteTemplateService
->pluck('value', 'key')
->toArray();
- return [
- 'title' => $settings['website_title'] ?? config('_var.appTitle'),
- 'author' => config('_var.author'),
- 'description' => $settings['website_description'] ?? config('_var.appDescription'),
- 'favicon' => $this->getFaviconPaths($settings),
- 'app_name' => $settings['website_app_name'] ?? config('_var.appName'),
- 'image_logo' => $this->getImageLogoPaths($settings),
- 'template' => $this->getTemplateVars($settings),
- 'google' => $this->getGoogleVars($settings),
- 'chat' => $this->getChatVars($settings),
- 'contact' => $this->getContactVars(),
- 'social' => $this->getSocialVars(),
- ];
+ return $this->buildWebsiteVars($settings);
});
- return $setting
- ? $webVars[$setting]
- : $webVars;
+ return $setting ? ($webVars[$setting] ?? []) : $webVars;
} catch (\Exception $e) {
- echo __METHOD__;
- echo " " . $e->getMessage() . "
";
- die('You must configure the database.');
+ // Manejo de excepciones: devolver valores predeterminados
+ return $this->getDefaultWebsiteVars($setting);
}
}
+ /**
+ * Construye las variables del sitio web.
+ */
+ private function buildWebsiteVars(array $settings): array
+ {
+ return [
+ 'title' => $settings['website_title'] ?? config('_var.appTitle'),
+ 'author' => config('_var.author'),
+ 'description' => $settings['website_description'] ?? config('_var.appDescription'),
+ 'favicon' => $this->getFaviconPaths($settings),
+ 'app_name' => $settings['website_app_name'] ?? config('_var.appName'),
+ 'image_logo' => $this->getImageLogoPaths($settings),
+ 'template' => $this->getTemplateVars($settings),
+ 'google' => $this->getGoogleVars($settings),
+ 'chat' => $this->getChatVars($settings),
+ 'contact' => $this->getContactVars(),
+ 'social' => $this->getSocialVars(),
+ ];
+ }
+
+ /**
+ * Devuelve las variables predeterminadas del sitio web.
+ */
+ private function getDefaultWebsiteVars(string $setting = ''): array
+ {
+ $defaultVars = [
+ 'title' => config('_var.appTitle', 'Default Title'),
+ 'author' => config('_var.author', 'Default Author'),
+ 'description' => config('_var.appDescription', 'Default Description'),
+ 'favicon' => $this->getFaviconPaths([]),
+ 'app_name' => config('_var.appName', 'Default App Name'),
+ 'image_logo' => $this->getImageLogoPaths([]),
+ 'template' => $this->getTemplateVars([]),
+ 'google' => $this->getGoogleVars([]),
+ 'chat' => $this->getChatVars([]),
+ 'contact' => [],
+ 'social' => [],
+ ];
+
+ return $setting ? ($defaultVars[$setting] ?? []) : $defaultVars;
+ }
+
/**
* Obtiene los paths de favicon en distintos tamaños.
*/
@@ -269,4 +302,4 @@ class WebsiteTemplateService
? $legalDocuments[$legalDocument]
: $legalDocuments;
}
-}
+}
\ No newline at end of file
diff --git a/composer.json b/composer.json
index ad3ecb3..2db5142 100644
--- a/composer.json
+++ b/composer.json
@@ -1,12 +1,14 @@
{
- "name": "koneko/laravel-vuexy-admin",
+ "name": "koneko/laravel-vuexy-admin-mexico",
"type": "project",
- "description": "Template Laravel Vuexy Admin with fortify, Spatie, Redis, Taillwind and more...",
+ "description": "Laravel Vuexy Admin para México. Un proyecto optimizado para México.",
"keywords": [
"laravel",
"framework",
"vuexy",
- "admin"
+ "admin",
+ "mexico",
+ "Catálogos SAT"
],
"license": "MIT",
"require": {
@@ -80,4 +82,4 @@
},
"minimum-stability": "stable",
"prefer-stable": true
-}
\ No newline at end of file
+}
diff --git a/composer.lock b/composer.lock
index 8bfa8fa..c752b8a 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "74ca673c06906baa677d4fc9af44d6a5",
+ "content-hash": "08a4f5e6c8df4c107ea90b13425f6396",
"packages": [
{
"name": "bacon/bacon-qr-code",
diff --git a/config/auth.php b/config/auth.php
index 84b4665..0ba5d5d 100644
--- a/config/auth.php
+++ b/config/auth.php
@@ -2,114 +2,114 @@
return [
- /*
- |--------------------------------------------------------------------------
- | Authentication Defaults
- |--------------------------------------------------------------------------
- |
- | This option defines the default authentication "guard" and password
- | reset "broker" for your application. You may change these values
- | as required, but they're a perfect start for most applications.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Authentication Defaults
+ |--------------------------------------------------------------------------
+ |
+ | This option defines the default authentication "guard" and password
+ | reset "broker" for your application. You may change these values
+ | as required, but they're a perfect start for most applications.
+ |
+ */
- 'defaults' => [
- 'guard' => env('AUTH_GUARD', 'web'),
- 'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
- ],
-
- /*
- |--------------------------------------------------------------------------
- | Authentication Guards
- |--------------------------------------------------------------------------
- |
- | Next, you may define every authentication guard for your application.
- | Of course, a great default configuration has been defined for you
- | which utilizes session storage plus the Eloquent user provider.
- |
- | All authentication guards have a user provider, which defines how the
- | users are actually retrieved out of your database or other storage
- | system used by the application. Typically, Eloquent is utilized.
- |
- | Supported: "session"
- |
- */
-
- 'guards' => [
- 'web' => [
- 'driver' => 'session',
- 'provider' => 'users',
- ],
- ],
-
- /*
- |--------------------------------------------------------------------------
- | User Providers
- |--------------------------------------------------------------------------
- |
- | All authentication guards have a user provider, which defines how the
- | users are actually retrieved out of your database or other storage
- | system used by the application. Typically, Eloquent is utilized.
- |
- | If you have multiple user tables or models you may configure multiple
- | providers to represent the model / table. These providers may then
- | be assigned to any extra authentication guards you have defined.
- |
- | Supported: "database", "eloquent"
- |
- */
-
- 'providers' => [
- 'users' => [
- 'driver' => 'eloquent',
- 'model' => env('AUTH_MODEL', Modules\Admin\App\Models\User::class),
+ 'defaults' => [
+ 'guard' => env('AUTH_GUARD', 'web'),
+ 'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
],
- // 'users' => [
- // 'driver' => 'database',
- // 'table' => 'users',
- // ],
- ],
+ /*
+ |--------------------------------------------------------------------------
+ | Authentication Guards
+ |--------------------------------------------------------------------------
+ |
+ | Next, you may define every authentication guard for your application.
+ | Of course, a great default configuration has been defined for you
+ | which utilizes session storage plus the Eloquent user provider.
+ |
+ | All authentication guards have a user provider, which defines how the
+ | users are actually retrieved out of your database or other storage
+ | system used by the application. Typically, Eloquent is utilized.
+ |
+ | Supported: "session"
+ |
+ */
- /*
- |--------------------------------------------------------------------------
- | Resetting Passwords
- |--------------------------------------------------------------------------
- |
- | These configuration options specify the behavior of Laravel's password
- | reset functionality, including the table utilized for token storage
- | and the user provider that is invoked to actually retrieve users.
- |
- | The expiry time is the number of minutes that each reset token will be
- | considered valid. This security feature keeps tokens short-lived so
- | they have less time to be guessed. You may change this as needed.
- |
- | The throttle setting is the number of seconds a user must wait before
- | generating more password reset tokens. This prevents the user from
- | quickly generating a very large amount of password reset tokens.
- |
- */
-
- 'passwords' => [
- 'users' => [
- 'provider' => 'users',
- 'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
- 'expire' => 60,
- 'throttle' => 60,
+ 'guards' => [
+ 'web' => [
+ 'driver' => 'session',
+ 'provider' => 'users',
+ ],
],
- ],
- /*
- |--------------------------------------------------------------------------
- | Password Confirmation Timeout
- |--------------------------------------------------------------------------
- |
- | Here you may define the amount of seconds before a password confirmation
- | window expires and users are asked to re-enter their password via the
- | confirmation screen. By default, the timeout lasts for three hours.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | User Providers
+ |--------------------------------------------------------------------------
+ |
+ | All authentication guards have a user provider, which defines how the
+ | users are actually retrieved out of your database or other storage
+ | system used by the application. Typically, Eloquent is utilized.
+ |
+ | If you have multiple user tables or models you may configure multiple
+ | providers to represent the model / table. These providers may then
+ | be assigned to any extra authentication guards you have defined.
+ |
+ | Supported: "database", "eloquent"
+ |
+ */
- 'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
+ 'providers' => [
+ 'users' => [
+ 'driver' => 'eloquent',
+ 'model' => env('AUTH_MODEL', App\Models\User::class),
+ ],
+
+ // 'users' => [
+ // 'driver' => 'database',
+ // 'table' => 'users',
+ // ],
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Resetting Passwords
+ |--------------------------------------------------------------------------
+ |
+ | These configuration options specify the behavior of Laravel's password
+ | reset functionality, including the table utilized for token storage
+ | and the user provider that is invoked to actually retrieve users.
+ |
+ | The expiry time is the number of minutes that each reset token will be
+ | considered valid. This security feature keeps tokens short-lived so
+ | they have less time to be guessed. You may change this as needed.
+ |
+ | The throttle setting is the number of seconds a user must wait before
+ | generating more password reset tokens. This prevents the user from
+ | quickly generating a very large amount of password reset tokens.
+ |
+ */
+
+ 'passwords' => [
+ 'users' => [
+ 'provider' => 'users',
+ 'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
+ 'expire' => 60,
+ 'throttle' => 60,
+ ],
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Password Confirmation Timeout
+ |--------------------------------------------------------------------------
+ |
+ | Here you may define the amount of seconds before a password confirmation
+ | window expires and users are asked to re-enter their password via the
+ | confirmation screen. By default, the timeout lasts for three hours.
+ |
+ */
+
+ 'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
];
diff --git a/config/excel.php b/config/excel.php
index c1fd34a..00ddd65 100644
--- a/config/excel.php
+++ b/config/excel.php
@@ -100,7 +100,7 @@ return [
| ignored by enabling the setting ignore_empty to true.
|
*/
- 'ignore_empty' => false,
+ 'ignore_empty' => true,
/*
|--------------------------------------------------------------------------
diff --git a/modules/Admin/App/Services/AdminTemplateService.php b/modules/Admin/App/Services/AdminTemplateService.php
index 80f74e8..86831d7 100644
--- a/modules/Admin/App/Services/AdminTemplateService.php
+++ b/modules/Admin/App/Services/AdminTemplateService.php
@@ -4,6 +4,7 @@ namespace Modules\Admin\App\Services;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Config;
+use Illuminate\Support\Facades\Schema;
use Modules\Admin\App\Models\Setting;
class AdminTemplateService
@@ -20,35 +21,61 @@ class AdminTemplateService
return $setting->save();
}
- public function getAdminVars($adminSetting = false)
+ public function getAdminVars($adminSetting = false): array
{
try {
+ // Verificar si el sistema está inicializado (la tabla `migrations` existe)
+ if (!Schema::hasTable('migrations')) {
+ return $this->getDefaultAdminVars($adminSetting);
+ }
+
+ // Cargar desde el caché o la base de datos si está disponible
return Cache::remember('admin_settings', $this->cacheTTL, function () use ($adminSetting) {
$settings = Setting::global()
->where('key', 'LIKE', 'admin_%')
->pluck('value', 'key')
->toArray();
- $adminSettings = [
- 'title' => $settings['admin_title'] ?? config('_var.appTitle'),
- 'author' => config('_var.author'),
- 'description' => config('_var.description'),
- 'favicon' => $this->getFaviconPaths($settings),
- 'app_name' => $settings['admin_app_name'] ?? config('_var.appName'),
- 'image_logo' => $this->getImageLogoPaths($settings),
- ];
+ $adminSettings = $this->buildAdminVarsArray($settings);
return $adminSetting
? $adminSettings[$adminSetting]
: $adminSettings;
});
} catch (\Exception $e) {
- echo __METHOD__;
- echo " " . $e->getMessage() . "
";
- die('You must configure the database.');
+ // En caso de error, devolver valores predeterminados
+ return $this->getDefaultAdminVars($adminSetting);
}
}
+ private function getDefaultAdminVars($adminSetting = false): array
+ {
+ $defaultSettings = [
+ 'title' => config('_var.appTitle', 'Default Title'),
+ 'author' => config('_var.author', 'Default Author'),
+ 'description' => config('_var.description', 'Default Description'),
+ 'favicon' => $this->getFaviconPaths([]),
+ 'app_name' => config('_var.appName', 'Default App Name'),
+ 'image_logo' => $this->getImageLogoPaths([]),
+ ];
+
+ return $adminSetting
+ ? $defaultSettings[$adminSetting] ?? null
+ : $defaultSettings;
+ }
+
+ private function buildAdminVarsArray(array $settings): array
+ {
+ return [
+ 'title' => $settings['admin_title'] ?? config('_var.appTitle'),
+ 'author' => config('_var.author'),
+ 'description' => config('_var.description'),
+ 'favicon' => $this->getFaviconPaths($settings),
+ 'app_name' => $settings['admin_app_name'] ?? config('_var.appName'),
+ 'image_logo' => $this->getImageLogoPaths($settings),
+ ];
+ }
+
public function getVuexyCustomizerVars()
{
// Obtener valores de la base de datos
@@ -126,4 +153,4 @@ class AdminTemplateService
{
Cache::forget("admin_settings");
}
-}
\ No newline at end of file
+}
diff --git a/modules/Admin/App/Services/GlobalSettingsService.php b/modules/Admin/App/Services/GlobalSettingsService.php
index b935dc9..37d4364 100644
--- a/modules/Admin/App/Services/GlobalSettingsService.php
+++ b/modules/Admin/App/Services/GlobalSettingsService.php
@@ -6,6 +6,7 @@ use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Crypt;
+use Illuminate\Support\Facades\Schema;
use Modules\Admin\App\Models\Setting;
class GlobalSettingsService
@@ -34,29 +35,57 @@ class GlobalSettingsService
public function loadSystemConfig(): void
{
try {
- $config = Cache::remember('global_system_config', $this->cacheTTL, function () {
- $settings = Setting::global()
- ->where('key', 'LIKE', 'config.%')
- ->pluck('value', 'key')
- ->toArray();
+ if (!Schema::hasTable('migrations')) {
+ // Base de datos no inicializada: usar valores predeterminados
+ $config = $this->getDefaultSystemConfig();
+ } else {
+ // Cargar configuración desde la caché o base de datos
+ $config = Cache::remember('global_system_config', $this->cacheTTL, function () {
+ $settings = Setting::global()
+ ->where('key', 'LIKE', 'config.%')
+ ->pluck('value', 'key')
+ ->toArray();
- return [
- 'servicesFacebook' => $this->buildServiceConfig($settings, 'config.services.facebook.', 'services.facebook'),
- 'servicesGoogle' => $this->buildServiceConfig($settings, 'config.services.google.', 'services.google'),
- 'custom' => $this->buildVuexyCustomConfig($settings),
- ];
- });
+ return [
+ 'servicesFacebook' => $this->buildServiceConfig($settings, 'config.services.facebook.', 'services.facebook'),
+ 'servicesGoogle' => $this->buildServiceConfig($settings, 'config.services.google.', 'services.google'),
+ 'custom' => $this->buildVuexyCustomConfig($settings),
+ ];
+ });
+ }
+ // Aplicar configuración al sistema
Config::set('services.facebook', $config['servicesFacebook']);
Config::set('services.google', $config['servicesGoogle']);
Config::set('custom', $config['custom']);
} catch (\Exception $e) {
- echo __METHOD__;
- echo " " . $e->getMessage() . "