First Commit

This commit is contained in:
marco
2026-09-01 10:46:29 -03:00
commit bf96b77e9c
10000 changed files with 3508600 additions and 0 deletions
@@ -0,0 +1,57 @@
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Schema\Blueprint;
class CreateSystemConfigTables
{
public function up()
{
// System Config
if (!Capsule::schema()->hasTable('system_config')) {
Capsule::schema()->create('system_config', function (Blueprint $table) {
$table->increments('system_config_id');
$table->string('system_config_key')->unique();
$table->text('system_config_value')->nullable();
$table->string('system_config_type')->default('string'); // string, boolean, integer, json
$table->text('system_config_description')->nullable();
$table->boolean('system_config_is_public')->default(false);
$table->integer('system_config_updated_by')->unsigned()->nullable();
$table->timestamps();
});
}
// Modules Table (Core table, placed here for system initialization)
if (!Capsule::schema()->hasTable('modules')) {
Capsule::schema()->create('modules', function (Blueprint $table) {
$table->increments('modules_id');
$table->string('modules_name')->unique(); // Folder name
$table->string('modules_display_name')->nullable();
$table->text('modules_description')->nullable();
$table->string('modules_version')->default('1.0.0');
$table->string('modules_author')->nullable();
$table->boolean('modules_ative')->default(false);
$table->boolean('modules_public')->default(false);
$table->boolean('modules_blocked')->default(false);
$table->json('modules_dependencies')->nullable();
$table->json('modules_permissions')->nullable();
$table->json('modules_settings')->nullable();
$table->string('modules_path')->nullable();
$table->string('modules_namespace')->nullable();
$table->string('modules_icon')->nullable();
$table->boolean('menu_side_bar')->default(false);
$table->boolean('menu_nav_bar')->default(false);
$table->integer('modules_order')->default(0);
$table->timestamp('modules_install_date')->nullable();
$table->timestamp('modules_update_date')->nullable();
$table->timestamps();
});
}
}
public function down()
{
Capsule::schema()->dropIfExists('modules');
Capsule::schema()->dropIfExists('system_config');
}
}
@@ -0,0 +1,76 @@
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
use App\Models\Module;
use Modules\Company\Models\Company;
class InsertSystemConfigModule
{
public function up()
{
$moduleData = [
'modules_name' => 'systemconfig',
'modules_display_name' => 'Configurações do Sistema',
'modules_description' => 'Módulo de configuração geral do sistema SysCMS',
'modules_version' => '1.0.0',
'modules_author' => 'SysCMS Team',
'modules_ative' => true,
'modules_public' => false,
'modules_blocked' => false,
'modules_dependencies' => [],
'modules_permissions' => [
"systemconfig.view",
"systemconfig.edit"
],
'modules_settings' => [],
'modules_path' => 'modules/systemconfig',
'modules_namespace' => 'Modules\\SystemConfig',
'modules_icon' => 'bi bi-gear', // Inferred as none in json, but good practice
'menu_side_bar' => true,
'menu_nav_bar' => false,
'modules_order' => 99, // Usually high number for settings
'modules_install_date' => date('Y-m-d H:i:s'),
'modules_update_date' => date('Y-m-d H:i:s')
];
$existingModule = Module::where('modules_name', 'systemconfig')->first();
if (!$existingModule) {
$module = Module::create($moduleData);
if (Capsule::schema()->hasTable('bus')) {
$companies = Company::all();
foreach ($companies as $company) {
$exists = Capsule::table('bus_modules')
->where('bus_modules_bus_id', $company->bus_id)
->where('bus_modules_module_id', $module->modules_id)
->exists();
if (!$exists) {
Capsule::table('bus_modules')->insert([
'bus_modules_bus_id' => $company->bus_id,
'bus_modules_module_id' => $module->modules_id,
'bus_modules_is_enabled' => true,
'bus_modules_settings' => json_encode([]),
'bus_modules_enabled_by' => 1,
'bus_modules_enabled_at' => date('Y-m-d H:i:s'),
'bus_modules_show_public_nav' => true,
'bus_modules_show_dashboard_nav' => true,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
]);
}
}
}
}
}
public function down()
{
$module = Module::where('modules_name', 'systemconfig')->first();
if ($module) {
Capsule::table('bus_modules')->where('bus_modules_module_id', $module->modules_id)->delete();
$module->delete();
}
}
}
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
class AddActiveThemeToConfig
{
public function up()
{
$exists = Capsule::table('system_config')
->where('system_config_key', 'active_theme')
->exists();
if (!$exists) {
Capsule::table('system_config')->insert([
'system_config_key' => 'active_theme',
'system_config_value' => 'default',
'system_config_type' => 'string',
'system_config_description' => 'O tema atualmente ativo no sistema.',
'system_config_is_public' => true,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
]);
}
}
public function down()
{
Capsule::table('system_config')
->where('system_config_key', 'active_theme')
->delete();
}
}