First Commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateConfigPagesTable
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
if (!Capsule::schema()->hasTable('config_index')) {
|
||||
Capsule::schema()->create('config_index', function (Blueprint $table) {
|
||||
$table->increments('config_index_id');
|
||||
$table->integer('config_index_bus_id')->unsigned()->default(1);
|
||||
$table->string('config_index_key')->index();
|
||||
$table->string('config_index_title');
|
||||
$table->longText('config_index_content')->nullable();
|
||||
$table->string('config_index_meta_title')->nullable();
|
||||
$table->text('config_index_meta_description')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['config_index_bus_id', 'config_index_key'], 'unique_page_per_bus');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Capsule::schema()->dropIfExists('config_index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use App\Models\Module;
|
||||
use Modules\Company\Models\Company;
|
||||
|
||||
class InsertModuleRecord
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
// Rename existing 'configpages' record to 'configindex' if present
|
||||
$existingOld = Module::where('modules_name', 'configpages')->first();
|
||||
if ($existingOld) {
|
||||
$settings = $existingOld->modules_settings ?? [];
|
||||
// Update menu route inside settings if structured as expected
|
||||
if (is_array($settings) && isset($settings['menu']['dashboard'])) {
|
||||
$settings['menu']['dashboard']['route'] = 'admin.configindex.index';
|
||||
$settings['menu']['dashboard']['label'] = 'Páginas Index';
|
||||
}
|
||||
|
||||
$existingOld->modules_name = 'configindex';
|
||||
$existingOld->modules_permissions = ['configindex.view', 'configindex.edit'];
|
||||
$existingOld->modules_path = 'modules/configindex';
|
||||
$existingOld->modules_namespace = 'Modules\\Configindex';
|
||||
$existingOld->modules_settings = $settings;
|
||||
$existingOld->modules_update_date = date('Y-m-d H:i:s');
|
||||
$existingOld->save();
|
||||
return; // Updated existing record; skip creation below
|
||||
}
|
||||
$moduleData = [
|
||||
'modules_name' => 'configindex',
|
||||
'modules_display_name' => 'Configuração de Páginas',
|
||||
'modules_description' => 'Gerenciamento de conteúdo das páginas Sobre, Contato e Serviços',
|
||||
'modules_version' => '1.0.0',
|
||||
'modules_author' => 'SysCMS Team',
|
||||
'modules_ative' => true,
|
||||
'modules_public' => false,
|
||||
'modules_blocked' => false,
|
||||
'modules_dependencies' => [],
|
||||
'modules_permissions' => ['configindex.view', 'configindex.edit'],
|
||||
'modules_settings' => [
|
||||
'menu' => [
|
||||
'dashboard' => [
|
||||
'icon' => 'bi bi-file-earmark-text',
|
||||
'label' => 'Páginas Index',
|
||||
'route' => 'admin.configindex.index',
|
||||
'order' => 20
|
||||
]
|
||||
]
|
||||
],
|
||||
'modules_path' => 'modules/configindex',
|
||||
'modules_namespace' => 'Modules\\Configindex',
|
||||
'modules_icon' => 'bi bi-file-earmark-text',
|
||||
'menu_side_bar' => true,
|
||||
'menu_nav_bar' => false,
|
||||
'modules_order' => 20,
|
||||
'modules_install_date' => date('Y-m-d H:i:s'),
|
||||
'modules_update_date' => date('Y-m-d H:i:s')
|
||||
];
|
||||
|
||||
// Check if module already exists
|
||||
$existingModule = Module::where('modules_name', 'configindex')->first();
|
||||
|
||||
if (!$existingModule) {
|
||||
$module = Module::create($moduleData);
|
||||
|
||||
// Associate with all existing companies (bus_modules)
|
||||
$companies = Company::all();
|
||||
foreach ($companies as $company) {
|
||||
// Check if already associated
|
||||
$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, // System or Admin
|
||||
'bus_modules_enabled_at' => date('Y-m-d H:i:s'),
|
||||
'bus_modules_show_public_nav' => false,
|
||||
'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', 'configindex')->first();
|
||||
if ($module) {
|
||||
// Remove associations
|
||||
Capsule::table('bus_modules')->where('bus_modules_module_id', $module->modules_id)->delete();
|
||||
// Delete module
|
||||
$module->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class AddNavVisibilityToConfigPages
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
if (Capsule::schema()->hasTable('config_index')) {
|
||||
if (!Capsule::schema()->hasColumn('config_index', 'config_index_show_public_nav')) {
|
||||
Capsule::schema()->table('config_index', function (Blueprint $table) {
|
||||
$table->boolean('config_index_show_public_nav')->default(true)->after('config_index_meta_description');
|
||||
});
|
||||
}
|
||||
if (!Capsule::schema()->hasColumn('config_index', 'config_index_show_dashboard_nav')) {
|
||||
Capsule::schema()->table('config_index', function (Blueprint $table) {
|
||||
$table->boolean('config_index_show_dashboard_nav')->default(true)->after('config_index_show_public_nav');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
if (Capsule::schema()->hasTable('config_index')) {
|
||||
Capsule::schema()->table('config_index', function (Blueprint $table) {
|
||||
if (Capsule::schema()->hasColumn('config_index', 'config_index_show_public_nav')) {
|
||||
$table->dropColumn('config_index_show_public_nav');
|
||||
}
|
||||
if (Capsule::schema()->hasColumn('config_index', 'config_index_show_dashboard_nav')) {
|
||||
$table->dropColumn('config_index_show_dashboard_nav');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user