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,68 @@
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Schema\Blueprint;
class CreateCompanyModuleTables
{
public function up()
{
// Companies Table
if (!Capsule::schema()->hasTable('bus')) {
Capsule::schema()->create('bus', function (Blueprint $table) {
$table->increments('bus_id');
$table->string('bus_name');
$table->string('bus_slug')->unique();
$table->text('bus_description')->nullable();
$table->string('bus_logo')->nullable();
$table->string('bus_business_card')->nullable();
$table->string('bus_document')->nullable();
$table->string('bus_email')->nullable();
$table->string('bus_phone')->nullable();
$table->string('bus_address')->nullable();
$table->string('bus_city')->nullable();
$table->string('bus_state')->nullable();
$table->string('bus_country')->nullable();
$table->string('bus_postal_code')->nullable();
$table->string('bus_website')->nullable();
$table->string('bus_tax_id')->nullable();
$table->string('bus_type')->nullable(); // e.g., 'personal', 'business'
$table->enum('bus_status', ['active', 'inactive', 'suspended'])->default('active');
$table->json('bus_settings')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
// Company Modules Pivot Table
if (!Capsule::schema()->hasTable('bus_modules')) {
Capsule::schema()->create('bus_modules', function (Blueprint $table) {
$table->increments('bus_modules_id');
$table->integer('bus_modules_bus_id')->unsigned();
$table->integer('bus_modules_module_id')->unsigned();
$table->boolean('bus_modules_is_enabled')->default(true);
$table->json('bus_modules_settings')->nullable();
$table->integer('bus_modules_enabled_by')->unsigned()->nullable();
$table->timestamp('bus_modules_enabled_at')->useCurrent();
// Navigation visibility
$table->boolean('bus_modules_show_public_nav')->default(true);
$table->boolean('bus_modules_show_dashboard_nav')->default(true);
$table->timestamps();
$table->unique(['bus_modules_bus_id', 'bus_modules_module_id']);
$table->foreign('bus_modules_bus_id')->references('bus_id')->on('bus')->onDelete('cascade');
// Note: modules table is created in SystemConfig or Core, so we might need to be careful with foreign keys if order varies.
// Assuming modules table exists or will exist. If strict, we can add FK.
// $table->foreign('bus_modules_module_id')->references('modules_id')->on('modules')->onDelete('cascade');
});
}
}
public function down()
{
Capsule::schema()->dropIfExists('bus_modules');
Capsule::schema()->dropIfExists('bus');
}
}
@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Schema\Blueprint;
/**
* Migration: Add Date Format to Companies Table
*/
class AddDateFormatToCompaniesTable
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
if (Capsule::schema()->hasTable('bus')) {
Capsule::schema()->table('bus', function (Blueprint $table) {
if (!Capsule::schema()->hasColumn('bus', 'bus_date_format')) {
$table->string('bus_date_format', 20)->default('d/m/Y')->after('bus_status');
}
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
if (Capsule::schema()->hasTable('bus')) {
Capsule::schema()->table('bus', function (Blueprint $table) {
if (Capsule::schema()->hasColumn('bus', 'bus_date_format')) {
$table->dropColumn('bus_date_format');
}
});
}
}
}
@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Schema\Blueprint;
class AddNavVisibilityToBusModules
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
if (Capsule::schema()->hasTable('bus_modules')) {
Capsule::schema()->table('bus_modules', function (Blueprint $table) {
if (!Capsule::schema()->hasColumn('bus_modules', 'bus_modules_show_public_nav')) {
$table->boolean('bus_modules_show_public_nav')->default(true)->after('bus_modules_is_enabled');
}
if (!Capsule::schema()->hasColumn('bus_modules', 'bus_modules_show_dashboard_nav')) {
$table->boolean('bus_modules_show_dashboard_nav')->default(true)->after('bus_modules_show_public_nav');
}
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
if (Capsule::schema()->hasTable('bus_modules')) {
Capsule::schema()->table('bus_modules', function (Blueprint $table) {
$table->dropColumn(['bus_modules_show_public_nav', 'bus_modules_show_dashboard_nav']);
});
}
}
}
@@ -0,0 +1,87 @@
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
use App\Models\Module;
use Modules\Company\Models\Company;
class InsertCompanyModule
{
public function up()
{
$moduleData = [
'modules_name' => 'company',
'modules_display_name' => 'Company',
'modules_description' => 'Company management module',
'modules_version' => '1.0.0',
'modules_author' => 'SysCMS Team',
'modules_ative' => true,
'modules_public' => false,
'modules_blocked' => false,
'modules_dependencies' => ["auth"],
'modules_permissions' => [
"company.view",
"company.create",
"company.edit",
"company.delete"
],
'modules_settings' => [
'menu' => [
'dashboard' => [
'icon' => 'bi bi-building',
'label' => 'company.menu.dashboard',
'route' => 'admin/companies',
'order' => 30
]
]
],
'modules_path' => 'modules/company',
'modules_namespace' => 'Modules\\Company',
'modules_icon' => 'bi bi-building',
'menu_side_bar' => true,
'menu_nav_bar' => false,
'modules_order' => 30,
'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', 'company')->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', 'company')->first();
if ($module) {
Capsule::table('bus_modules')->where('bus_modules_module_id', $module->modules_id)->delete();
$module->delete();
}
}
}
@@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Database\Schema\Blueprint;
class AddPlatformNameToCompanies
{
public function up()
{
// Adiciona campo platform_name à tabela bus (companies)
if (Capsule::schema()->hasTable('bus') && !Capsule::schema()->hasColumn('bus', 'platform_name')) {
Capsule::schema()->table('bus', function (Blueprint $table) {
$table->string('platform_name')->nullable()->after('bus_name');
});
}
}
public function down()
{
if (Capsule::schema()->hasTable('bus') && Capsule::schema()->hasColumn('bus', 'platform_name')) {
Capsule::schema()->table('bus', function (Blueprint $table) {
$table->dropColumn('platform_name');
});
}
}
}