Updated ERP with new modules and features

This commit is contained in:
Kwesi Banson
2026-09-22 08:06:31 +00:00
parent 71bc103fee
commit 5174e82e51
53 changed files with 3706 additions and 203 deletions

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('servers', function (Blueprint $table) {
$table->id();
$table->string('name'); // e.g., "Main PBX Engine" or "Synology NAS"
$table->string('ip_address');
$table->string('os_version')->nullable(); // e.g., "AlmaLinux 9", "Debian"
$table->string('username')->default('root');
$table->text('password'); // Will be encrypted via Model casting
$table->json('services')->nullable(); // Array of services like ['Docker', 'PostGIS', 'Dovecot']
$table->string('status')->default('Active');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('servers');
}
};

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('password_access_audits', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('server_id')->constrained()->cascadeOnDelete();
$table->string('ip_address');
$table->string('user_agent')->nullable();
$table->timestamp('accessed_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('password_access_audits');
}
};

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('vpn_configs', function (Blueprint $table) {
$table->id();
$table->string('partner_name'); // e.g., "MTN Ghana" or "Telecel"
$table->string('peer_ip'); // Partner's Gateway
$table->string('local_ip'); // Your Gateway
$table->string('encryption_domain_local')->nullable(); // Your internal subnets/VLANs
$table->string('encryption_domain_remote')->nullable(); // Partner's subnets
$table->text('preshared_key'); // Encrypted
$table->string('status')->default('Active');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('vpn_configs');
}
};

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::table('vpn_configs', function (Blueprint $table) {
// General Info
$table->string('local_device')->nullable()->after('peer_ip');
$table->string('peer_device')->nullable()->after('local_device');
// Phase 1 (IKE)
$table->integer('ike_version')->default(2)->after('preshared_key');
$table->string('phase1_encryption')->default('AES-256')->after('ike_version');
$table->string('phase1_hash')->default('SHA-256')->after('phase1_encryption');
$table->string('phase1_dh_group')->default('14')->after('phase1_hash');
$table->integer('phase1_lifetime')->default(28800)->after('phase1_dh_group');
// Phase 2 (IPSec)
$table->string('phase2_encryption')->default('AES-256')->after('phase1_lifetime');
$table->string('phase2_hash')->default('SHA-256')->after('phase2_encryption');
$table->string('phase2_dh_group')->nullable()->after('phase2_hash');
$table->integer('phase2_lifetime')->default(3600)->after('phase2_dh_group');
$table->boolean('pfs_enabled')->default(true)->after('phase2_lifetime');
});
}
public function down()
{
Schema::table('vpn_configs', function (Blueprint $table) {
$table->dropColumn([
'local_device', 'peer_device', 'ike_version',
'phase1_encryption', 'phase1_hash', 'phase1_dh_group', 'phase1_lifetime',
'phase2_encryption', 'phase2_hash', 'phase2_dh_group', 'phase2_lifetime', 'pfs_enabled'
]);
});
}
};

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::create('activity_logs', function (Blueprint $table) {
$table->id();$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
// This creates `loggable_type` and `loggable_id` to link to ANY model
$table->morphs('loggable');
$table->string('action'); // 'created', 'updated', 'deleted'$table->json('old_data')->nullable(); // State before update
$table->json('new_data')->nullable(); // State after update$table->string('ip_address')->nullable();
$table->string('user_agent')->nullable();$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('activity_logs');
}
};

View File

@@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::table('activity_logs', function (Blueprint $table) {
$table->json('old_data')->nullable()->after('action');
$table->string('ip_address')->nullable()->after('new_data');
});
}
public function down()
{
Schema::table('activity_logs', function (Blueprint $table) {
$table->dropColumn(['old_data', 'ip_address']);
});
}
};

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function upSIde()
{
Schema::create('network_operator_documents', function (Blueprint $table) {
$table->id();
$table->foreignId('network_operator_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->string('file_path');
$table->timestamps();
});
}
public function up()
{
Schema::create('network_operator_documents', function (Blueprint $table) {
$table->id();
// Explicitly define as standard unsigned integer to match older tables
$table->unsignedInteger('network_operator_id');
$table->string('name');
$table->string('file_path');
$table->timestamps();
// Explicitly define the constraint
$table->foreign('network_operator_id')
->references('id')
->on('network_operators')
->onDelete('cascade');
});
}
public function down()
{
Schema::dropIfExists('network_operator_documents');
}
};