chore: update document approval workflow and bug fixes

This commit is contained in:
2026-05-25 13:05:20 +08:00
parent d573c02893
commit 39a8e1d4cd
910 changed files with 49994 additions and 1010 deletions

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(): void
{
Schema::table('users', function (Blueprint $table) {
$table->enum('user_type', ['admin', 'employee', 'customer'])->default('employee')->after('email');
$table->enum('status', ['active', 'inactive', 'suspended'])->default('active')->after('user_type');
$table->string('userable_type')->nullable()->after('status');
$table->unsignedBigInteger('userable_id')->nullable()->after('userable_type');
$table->index(['userable_type', 'userable_id']);
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropIndex(['userable_type', 'userable_id']);
$table->dropColumn(['user_type', 'status', 'userable_type', 'userable_id']);
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('employee_profiles', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('department')->nullable();
$table->string('position')->nullable();
$table->string('employee_code')->unique()->nullable();
$table->date('hire_date')->nullable();
$table->string('phone')->nullable();
$table->text('address')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('employee_profiles');
}
};

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(): void
{
Schema::create('customer_profiles', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('company_name')->nullable();
$table->string('contact_person')->nullable();
$table->string('tin_number')->nullable();
$table->string('phone')->nullable();
$table->text('address')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('customer_profiles');
}
};

View File

@@ -0,0 +1,18 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
DB::statement("ALTER TABLE users MODIFY COLUMN user_type ENUM('admin', 'employee', 'customer', 'contractor') DEFAULT 'employee'");
}
public function down(): void
{
DB::statement("ALTER TABLE users MODIFY COLUMN user_type ENUM('admin', 'employee', 'customer') DEFAULT 'employee'");
}
};

View File

@@ -0,0 +1,64 @@
<?php
namespace Modules\UserManagement\Database\Seeders;
use App\Models\User;
use Illuminate\Database\Seeder;
use Modules\UserManagement\Models\EmployeeProfile;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;
class UserManagementDatabaseSeeder extends Seeder
{
public function run(): void
{
// Create permissions
$permissions = [
'users.view',
'users.create',
'users.edit',
'users.delete',
'users.manage-status',
];
foreach ($permissions as $permission) {
Permission::firstOrCreate(['name' => $permission]);
}
// Create roles with permissions
$adminRole = Role::firstOrCreate(['name' => 'admin']);
$adminRole->syncPermissions($permissions);
$employeeRole = Role::firstOrCreate(['name' => 'employee']);
$employeeRole->syncPermissions(['users.view']);
$customerRole = Role::firstOrCreate(['name' => 'customer']);
// Create default admin user
$admin = User::firstOrCreate(
['email' => 'admin@gsb-cons.com'],
[
'name' => 'System Admin',
'password' => bcrypt('password'),
'user_type' => 'admin',
'status' => 'active',
]
);
$admin->assignRole('admin');
$profile = EmployeeProfile::firstOrCreate(
['user_id' => $admin->id],
[
'department' => 'Administration',
'position' => 'System Administrator',
'employee_code' => 'EMP-0001',
'hire_date' => now(),
]
);
$admin->update([
'userable_type' => EmployeeProfile::class,
'userable_id' => $profile->id,
]);
}
}