miscellaneous updates
This commit is contained in:
@ -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 "<br>" . $e->getMessage() . "<br><br>";
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 "<br>" . $e->getMessage() . "<br><br>";
|
||||
die('You must configure the database.');
|
||||
// Manejo silencioso de errores para evitar interrupciones
|
||||
Config::set('services.facebook', config('services.facebook', []));
|
||||
Config::set('services.google', config('services.google', []));
|
||||
Config::set('custom', config('custom', []));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve una configuración predeterminada si la base de datos no está inicializada.
|
||||
*/
|
||||
private function getDefaultSystemConfig(): array
|
||||
{
|
||||
return [
|
||||
'servicesFacebook' => config('services.facebook', [
|
||||
'client_id' => '',
|
||||
'client_secret' => '',
|
||||
'redirect' => '',
|
||||
]),
|
||||
'servicesGoogle' => config('services.google', [
|
||||
'client_id' => '',
|
||||
'client_secret' => '',
|
||||
'redirect' => '',
|
||||
]),
|
||||
'custom' => config('custom', []),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica si un bloque de configuraciones está presente.
|
||||
*/
|
||||
|
@ -26,8 +26,6 @@ class WebsiteSettingsService
|
||||
private $imageLogoMaxPixels2 = 75625; // Segunda versión (px^2) en Base64
|
||||
private $imageLogoMaxPixels3 = 230400; // Tercera versión (px^2)
|
||||
|
||||
protected $cacheTTL = 60 * 24 * 30; // 30 días en minutos
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->driver = config('image.driver', 'gd');
|
||||
|
@ -1,14 +1,14 @@
|
||||
name,email,role
|
||||
Administrador Web,webadmin@concierge.test,Administrador Web
|
||||
Productos y servicios,productos@concierge.test,Productos y servicios
|
||||
Recursos humanos,rrhh@concierge.test,Recursos humanos
|
||||
Nómina,nomina@concierge.test,Nómina
|
||||
Activos fijos,activos@concierge.test,Activos fijos
|
||||
Compras y gastos,compras@concierge.test,Compras y gastos
|
||||
CRM,crm@concierge.test,CRM
|
||||
Vendedor,vendedor@concierge.test,Vendedor
|
||||
Gerente,gerente@concierge.test,Gerente
|
||||
Facturación,facturacion@concierge.test,Facturación
|
||||
Facturación avanzado,facturacion_avanzado@concierge.test,Facturación avanzado
|
||||
Finanzas,finanzas@concierge.test,Finanzas
|
||||
Auditor,auditor@concierge.test,Auditor
|
||||
name,email,role,password
|
||||
Administrador Web,webadmin@concierge.test,Administrador Web,LAdmin123
|
||||
Productos y servicios,productos@concierge.test,Productos y servicios,LAdmin123
|
||||
Recursos humanos,rrhh@concierge.test,Recursos humanos,LAdmin123
|
||||
Nómina,nomina@concierge.test,Nómina,LAdmin123
|
||||
Activos fijos,activos@concierge.test,Activos fijos,LAdmin123
|
||||
Compras y gastos,compras@concierge.test,Compras y gastos,LAdmin123
|
||||
CRM,crm@concierge.test,CRM,LAdmin123
|
||||
Vendedor,vendedor@concierge.test,Vendedor,LAdmin123
|
||||
Gerente,gerente@concierge.test,Gerente,LAdmin123
|
||||
Facturación,facturacion@concierge.test,Facturación,LAdmin123
|
||||
Facturación avanzado,facturacion_avanzado@concierge.test,Facturación avanzado,LAdmin123
|
||||
Finanzas,finanzas@concierge.test,Finanzas,LAdmin123
|
||||
Auditor,auditor@concierge.test,Auditor,LAdmin123
|
||||
|
|
@ -10,7 +10,7 @@ class AdminDatabaseSeeder extends Seeder
|
||||
{
|
||||
$this->call(RoleSeeder::class);
|
||||
$this->call(UserSeeder::class);
|
||||
$this->call(SettingSeeder::class);
|
||||
//$this->call(SettingSeeder::class);
|
||||
$this->call(SATCatalogsSeeder::class);
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ class SettingSeeder extends Seeder
|
||||
public function run()
|
||||
{
|
||||
$settings_array = [
|
||||
/*
|
||||
'app_title' => 'Quimiplastic S.A de C.V.',
|
||||
'app_faviconIcon' => '../assets/img/logo/koneko-02.png',
|
||||
'app_name' => 'Quimiplastic',
|
||||
@ -96,7 +95,7 @@ class SettingSeeder extends Seeder
|
||||
'chat.whatsapp.message' => '👋 Hola! Estoy buscando más información sobre Covirsa Soluciones en Tecnología. ¿Podrías proporcionarme los detalles que necesito? ¡Te lo agradecería mucho! 💻✨',
|
||||
|
||||
'webTpl.container' => 'custom-container',
|
||||
*/];
|
||||
];
|
||||
|
||||
foreach ($settings_array as $key => $value) {
|
||||
Setting::create([
|
||||
|
77
modules/Admin/Database/seeders/UserSeeder.php
Normal file
77
modules/Admin/Database/seeders/UserSeeder.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Database\seeders;
|
||||
|
||||
use Modules\Admin\App\Models\User;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Define el disco y la carpeta
|
||||
$disk = 'public';
|
||||
$directory = 'profile-photos';
|
||||
|
||||
// Verifica si la carpeta existe
|
||||
if (Storage::disk($disk)->exists($directory))
|
||||
Storage::disk($disk)->deleteDirectory($directory);
|
||||
|
||||
// Arturo Corro
|
||||
$user = User::create([
|
||||
'name' => 'Koneko Admin',
|
||||
'email' => 'admin@koneko.mx',
|
||||
'email_verified_at' => now(),
|
||||
'password' => bcrypt('LAdmin123'),
|
||||
'status' => User::STATUS_ENABLED,
|
||||
])->assignRole('SuperAdmin');
|
||||
|
||||
$user->updateProfilePhoto(new UploadedFile(
|
||||
'public/assets/img/logo/koneko-02.png',
|
||||
'koneko-02.png'
|
||||
));
|
||||
|
||||
|
||||
// Webmaster admin
|
||||
$user = User::create([
|
||||
'name' => 'Admin',
|
||||
'email' => 'servers@koneko.mx',
|
||||
'email_verified_at' => now(),
|
||||
'password' => bcrypt('LAdmin123'),
|
||||
'status' => User::STATUS_ENABLED,
|
||||
])->assignRole('Admin');
|
||||
|
||||
$user->updateProfilePhoto(new UploadedFile(
|
||||
'public/assets/img/logo/koneko-03.png',
|
||||
'koneko-03.png'
|
||||
));
|
||||
|
||||
// Usuarios CSV
|
||||
$csvFile = fopen(base_path("modules/Admin/Database/data/users.csv"), "r");
|
||||
|
||||
$firstline = true;
|
||||
|
||||
while (($data = fgetcsv($csvFile, 2000, ",")) !== FALSE) {
|
||||
if (!$firstline) {
|
||||
User::create([
|
||||
'name' => $data['0'],
|
||||
'email' => $data['1'],
|
||||
'email_verified_at' => now(),
|
||||
'password' => bcrypt($data['3']),
|
||||
'status' => User::STATUS_ENABLED,
|
||||
])->assignRole($data['2']);
|
||||
}
|
||||
|
||||
$firstline = false;
|
||||
}
|
||||
|
||||
fclose($csvFile);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user