first commit
This commit is contained in:
65
database/seeders/CurrencySeeder.php
Normal file
65
database/seeders/CurrencySeeder.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Koneko\VuexyStoreManager\Models\Currency;
|
||||
|
||||
class CurrencySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Lista de divisas a insertar.
|
||||
*/
|
||||
protected static array $divisas = [
|
||||
[
|
||||
'c_currency' => 'MXN',
|
||||
'symbol' => '$',
|
||||
'auto_update_exchange_rates' => true,
|
||||
'refresh_interval' => 24,
|
||||
'status' => Currency::STATUS_ENABLED,
|
||||
],
|
||||
[
|
||||
'c_currency' => 'USD',
|
||||
'symbol' => '$',
|
||||
'auto_update_exchange_rates' => true,
|
||||
'refresh_interval' => 24,
|
||||
'status' => Currency::STATUS_ENABLED,
|
||||
],
|
||||
[
|
||||
'c_currency' => 'EUR',
|
||||
'symbol' => '€',
|
||||
'auto_update_exchange_rates' => true,
|
||||
'refresh_interval' => 24,
|
||||
'status' => Currency::STATUS_ENABLED,
|
||||
],
|
||||
[
|
||||
'c_currency' => 'GBP',
|
||||
'symbol' => '£',
|
||||
'auto_update_exchange_rates' => true,
|
||||
'refresh_interval' => 24,
|
||||
'status' => Currency::STATUS_ENABLED,
|
||||
],
|
||||
[
|
||||
'c_currency' => 'JPY',
|
||||
'symbol' => '¥',
|
||||
'auto_update_exchange_rates' => true,
|
||||
'refresh_interval' => 24,
|
||||
'status' => Currency::STATUS_ENABLED,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
foreach (self::$divisas as $divisa) {
|
||||
Currency::updateOrCreate(
|
||||
['c_currency' => $divisa['c_currency']], // Clave única
|
||||
$divisa // Valores a insertar/actualizar
|
||||
);
|
||||
}
|
||||
|
||||
$this->command->info('Divisas insertadas/actualizadas correctamente.');
|
||||
}
|
||||
}
|
24
database/seeders/DatabaseSeeder.php
Normal file
24
database/seeders/DatabaseSeeder.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this->call([
|
||||
SettingSeeder::class,
|
||||
PermissionSeeder::class,
|
||||
UserSeeder::class,
|
||||
SATCatalogsSeeder::class,
|
||||
UnidadConversionesSeeder::class,
|
||||
CurrencySeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
14
database/seeders/PermissionSeeder.php
Normal file
14
database/seeders/PermissionSeeder.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Koneko\VuexyAdmin\Services\RBACService;
|
||||
|
||||
class PermissionSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
RBACService::loadRolesAndPermissions();
|
||||
}
|
||||
}
|
135
database/seeders/SATCatalogsSeeder.php
Normal file
135
database/seeders/SATCatalogsSeeder.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Koneko\SatCatalogs\Imports\SatCatalogsImport;
|
||||
use Koneko\SatCatalogs\Models\Banco;
|
||||
use Koneko\SatCatalogs\Models\RegimenContratacion;
|
||||
use Koneko\SatCatalogs\Models\Deduccion;
|
||||
use Koneko\SatCatalogs\Models\Percepcion;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class SATCatalogsSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$file_path = database_path("data/catCFDI_V_4_20250213.xls");
|
||||
|
||||
$import = new SatCatalogsImport();
|
||||
|
||||
$import->onlySheets('c_ClaveProdServ');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_ClaveUnidad');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_CodigoPostal_Parte_1');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_CodigoPostal_Parte_2');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('C_Colonia_1');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('C_Colonia_2');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('C_Colonia_3');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_Estado');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_FormaPago');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('C_Localidad');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_Moneda');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('C_Municipio');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_Pais');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_RegimenFiscal');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
$import->onlySheets('c_UsoCFDI');
|
||||
Excel::import($import, $file_path);
|
||||
|
||||
|
||||
// Lee el archivo JSON desde el storage
|
||||
$json = File::get(database_path('data/catalogo_sat_bancos.json'));
|
||||
|
||||
// Convierte el contenido JSON a un array asociativo
|
||||
$bancos = json_decode($json, true);
|
||||
|
||||
// Inserta cada banco en la base de datos
|
||||
foreach ($bancos as $banco) {
|
||||
Banco::create([
|
||||
'c_banco' => $banco['c_banco'],
|
||||
'descripcion' => $banco['descripcion'],
|
||||
'razon_social' => $banco['razon_social'],
|
||||
'rfc' => null,
|
||||
'status' => Banco::STATUS_ENABLED
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// Leer el archivo JSON desde la ruta especificada
|
||||
$json = File::get(database_path('data/catalogo_sat_regimenes_contratacion.json'));
|
||||
|
||||
// Decodificar el JSON en un array asociativo
|
||||
$regimenes = json_decode($json, true);
|
||||
|
||||
// Insertar cada régimen en la base de datos
|
||||
foreach ($regimenes as $c_tipo_regimen => $descripcion) {
|
||||
RegimenContratacion::create([
|
||||
'c_tipo_regimen' => $c_tipo_regimen,
|
||||
'descripcion' => $descripcion,
|
||||
'fecha_inicio_de_vigencia' => null,
|
||||
'fecha_fin_de_vigencia' => null
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// Leer el archivo JSON desde la ruta especificada
|
||||
$json = File::get(database_path('data/catalogo_sat_percepciones_deducciones.json'));
|
||||
|
||||
// Decodificar el JSON en un array asociativo
|
||||
$catalogo = json_decode($json, true);
|
||||
|
||||
// Insertar percepciones
|
||||
foreach ($catalogo['percepciones'] as $percepcion) {
|
||||
Percepcion::create([
|
||||
'c_percepcion' => $percepcion['clave'],
|
||||
'descripcion' => $percepcion['descripcion'],
|
||||
'fecha_inicio_de_vigencia' => null,
|
||||
'fecha_fin_de_vigencia' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
// Insertar deducciones
|
||||
foreach ($catalogo['deducciones'] as $deduccion) {
|
||||
Deduccion::create([
|
||||
'c_deduccion' => $deduccion['clave'],
|
||||
'descripcion' => $deduccion['descripcion'],
|
||||
'fecha_inicio_de_vigencia' => null,
|
||||
'fecha_fin_de_vigencia' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
108
database/seeders/SettingSeeder.php
Normal file
108
database/seeders/SettingSeeder.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Koneko\VuexyAdmin\Models\Setting;
|
||||
|
||||
class SettingSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$settings_array = [
|
||||
/*
|
||||
'app_title' => 'Quimiplastic S.A de C.V.',
|
||||
'app_faviconIcon' => '../assets/img/logo/koneko-02.png',
|
||||
'app_name' => 'Quimiplastic',
|
||||
'app_imageLogo' => '../assets/img/logo/koneko-02.png',
|
||||
|
||||
'app_myLayout' => 'vertical',
|
||||
'app_myTheme' => 'theme-default',
|
||||
'app_myStyle' => 'light',
|
||||
'app_navbarType' => 'sticky',
|
||||
'app_menuFixed' => true,
|
||||
'app_menuCollapsed' => false,
|
||||
'app_headerType' => 'static',
|
||||
'app_showDropdownOnHover' => false,
|
||||
'app_authViewMode' => 'cover',
|
||||
'app_maxQuickLinks' => 5,
|
||||
|
||||
|
||||
|
||||
'smtp.host' => 'webmail.koneko.mx',
|
||||
'smtp.port' => 465,
|
||||
'smtp.encryption' => 'tls',
|
||||
'smtp.username' => 'no-responder@koneko.mx',
|
||||
'smtp.password' => null,
|
||||
'smtp.from_email' => 'no-responder@koneko.mx',
|
||||
'smtp.from_name' => 'Koneko Soluciones en Tecnología',
|
||||
'smtp.reply_to_method' => 'smtp',
|
||||
'smtp.reply_to_email' => null,
|
||||
'smtp.reply_to_name' => null,
|
||||
|
||||
|
||||
|
||||
'website.title',
|
||||
'website.favicon',
|
||||
'website.description',
|
||||
'website.image_logo',
|
||||
'website.image_logoDark',
|
||||
|
||||
'admin.title',
|
||||
'admin.favicon',
|
||||
'admin.description',
|
||||
'admin.image_logo',
|
||||
'admin.image_logoDark',
|
||||
|
||||
|
||||
'favicon.icon' => null,
|
||||
|
||||
'contact.phone_number' => '(222) 462 0903',
|
||||
'contact.phone_number_ext' => 'Ext. 5',
|
||||
'contact.email' => 'virtualcompras@live.com.mx',
|
||||
'contact.form.email' => 'contacto@conciergetravellife.com',
|
||||
'contact.form.email_cc' => 'arturo@koneko.mx',
|
||||
'contact.form.subject' => 'Has recibido un mensaje del formulario de covirsast.com',
|
||||
'contact.direccion' => '51 PTE 505 loc. 14, Puebla, Pue.',
|
||||
'contact.horario' => '9am - 7 pm',
|
||||
'contact.location.lat' => '19.024439',
|
||||
'contact.location.lng' => '-98.215777',
|
||||
|
||||
'social.whatsapp' => '',
|
||||
'social.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! 💻✨',
|
||||
|
||||
'social.facebook' => 'https://www.facebook.com/covirsast/?locale=es_LA',
|
||||
'social.Whatsapp' => '2228 200 201',
|
||||
'social.Whatsapp.message' => '¡Hola! 🌟 Estoy interesado en obtener más información acerca de Concierge Travel. ¿Podrías ayudarme con los detalles? ¡Gracias de antemano! ✈️🏝',
|
||||
'social.Facebook' => 'test',
|
||||
'social.Instagram' => 'test',
|
||||
'social.Linkedin' => 'test',
|
||||
'social.Tiktok' => 'test',
|
||||
'social.X_twitter' => 'test',
|
||||
'social.Google' => 'test',
|
||||
'social.Pinterest' => 'test',
|
||||
'social.Youtube' => 'test',
|
||||
'social.Vimeo' => 'test',
|
||||
|
||||
|
||||
'chat.provider' => '',
|
||||
'chat.whatsapp.number' => '',
|
||||
'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([
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
]);
|
||||
};
|
||||
}
|
||||
}
|
88
database/seeders/UnidadConversionesSeeder.php
Normal file
88
database/seeders/UnidadConversionesSeeder.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UnidadConversionesSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
// Cargar los datos desde el archivo JSON
|
||||
$jsonPath = database_path('data/catalogo_sat_unidad_de_conversiones.json');
|
||||
|
||||
// Comprobar si el archivo JSON existe
|
||||
if (!file_exists($jsonPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = json_decode(file_get_contents($jsonPath), true);
|
||||
|
||||
// Comprobar si el JSON se cargó correctamente
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Cargar todas las unidades existentes
|
||||
$unidadesExistentes = DB::table('sat_clave_unidad')->get()->keyBy('c_clave_unidad');
|
||||
|
||||
// Un array para almacenar las nuevas unidades que vamos a insertar
|
||||
$nuevasUnidades = [];
|
||||
|
||||
// Insertar o actualizar las unidades de medida
|
||||
foreach ($data['units'] as $unidad) {
|
||||
if (!isset($unidad['c_clave_unidad']) || trim($unidad['c_clave_unidad']) == '') {
|
||||
continue; // Ignorar si 'c_clave_unidad' es nulo o vacío
|
||||
}
|
||||
|
||||
// Verificamos si la unidad ya existe
|
||||
if (!isset($unidadesExistentes[$unidad['c_clave_unidad']])) {
|
||||
$nuevasUnidades[] = [
|
||||
'c_clave_unidad' => $unidad['c_clave_unidad'],
|
||||
'nombre' => $unidad['nombre'],
|
||||
'simbolo' => $unidad['simbolo'] ?? null,
|
||||
'categoria' => $unidad['categoria'] ?? null,
|
||||
'is_base' => false, // Define la lógica para is_base
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Insertar todas las nuevas unidades en un solo paso
|
||||
if (!empty($nuevasUnidades)) {
|
||||
DB::table('sat_clave_unidad')->insert($nuevasUnidades);
|
||||
}
|
||||
|
||||
// Volver a cargar las unidades existentes para las conversiones
|
||||
$unidadesExistentes = DB::table('sat_clave_unidad')->get()->keyBy('c_clave_unidad');
|
||||
|
||||
// Preparar un array para las conversiones a insertar
|
||||
$nuevasConversiones = [];
|
||||
|
||||
// Asegúrate de que 'conversions' existe en $data
|
||||
if (isset($data['conversions'])) {
|
||||
foreach ($data['conversions'] as $conversion) {
|
||||
$origen = $unidadesExistentes[$conversion['from_unit']] ?? null;
|
||||
$destino = $unidadesExistentes[$conversion['to_unit']] ?? null;
|
||||
|
||||
// Solo insertar si ambos IDs existen
|
||||
if ($origen && $destino) {
|
||||
$nuevasConversiones[] = [
|
||||
'clave_unidad_origen_id' => $origen->id,
|
||||
'clave_unidad_destino_id' => $destino->id,
|
||||
'conversion_factor' => $conversion['factor'],
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Insertar todas las conversiones en un solo paso
|
||||
if (!empty($nuevasConversiones)) {
|
||||
DB::table('sat_clave_unidad_conversiones')->insert($nuevasConversiones);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
97
database/seeders/UserSeeder.php
Normal file
97
database/seeders/UserSeeder.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Koneko\VuexyAdmin\Models\User;
|
||||
use Koneko\VuexyAdmin\Services\AvatarImageService;
|
||||
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);
|
||||
|
||||
//
|
||||
$avatarImageService = new AvatarImageService();
|
||||
|
||||
// Super admin
|
||||
$user = User::create([
|
||||
'name' => 'Koneko Admin',
|
||||
'email' => 'arturo@koneko.mx',
|
||||
'email_verified_at' => now(),
|
||||
'password' => bcrypt('LAdmin123'),
|
||||
'status' => User::STATUS_ENABLED,
|
||||
])->assignRole('SuperAdmin');
|
||||
|
||||
// Actualizamos la foto
|
||||
$avatarImageService->updateProfilePhoto($user, new UploadedFile(
|
||||
'public/vendor/vuexy-admin/img/logo/koneko-02.png',
|
||||
'koneko-02.png'
|
||||
));
|
||||
|
||||
|
||||
// admin
|
||||
$user = User::create([
|
||||
'name' => 'Admin',
|
||||
'email' => 'admin@koneko.mx',
|
||||
'email_verified_at' => now(),
|
||||
'password' => bcrypt('LAdmin123'),
|
||||
'status' => User::STATUS_ENABLED,
|
||||
])->assignRole('Admin');
|
||||
|
||||
$avatarImageService->updateProfilePhoto($user, new UploadedFile(
|
||||
'public/vendor/vuexy-admin/img/logo/koneko-03.png',
|
||||
'koneko-03.png'
|
||||
));
|
||||
|
||||
// Almacenista
|
||||
$user = User::create([
|
||||
'name' => 'Almacenista',
|
||||
'email' => 'almacenista@koneko.mx',
|
||||
'email_verified_at' => now(),
|
||||
'password' => bcrypt('LAdmin123'),
|
||||
'status' => User::STATUS_ENABLED,
|
||||
])->assignRole('Almacenista');
|
||||
|
||||
$avatarImageService->updateProfilePhoto($user, new UploadedFile(
|
||||
'public/vendor/vuexy-admin/img/logo/koneko-03.png',
|
||||
'koneko-03.png'
|
||||
));
|
||||
|
||||
|
||||
// Usuarios CSV
|
||||
$csvFile = fopen(base_path("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