feat(profile): add profile module with tenant-scoped user profiles#274
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR introduces a complete Profile module as a reusable Laravel package component alongside changes to tenant membership via a custom pivot model. The Profile module defines three Filament-integrated enums for seniority level, social platform, and start availability; an Eloquent model with relationships and validation for user profiles scoped to tenants; a migration establishing the underlying Possibly related issues
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app-modules/profile/src/ProfileServiceProvider.php`:
- Around line 25-26: The SQL matching is too strict: update the INSERT detection
in ProfileServiceProvider (the preg_match that checks $event->sql) to accept
optional leading whitespace, optional schema qualification, and either backtick
or double-quote quoting around identifiers (tenant_users), e.g. allow
`schema`.`tenant_users`, "schema"."tenant_users", or tenant_users; similarly,
harden insertColumns() to strip/normalize backticks and double-quotes and to
handle schema-qualified table names before extracting column lists — normalize
the SQL (lowercase for matching, remove/replace surrounding quotes on
identifiers) then apply relaxed regexes so schema-qualified and backtick-quoted
INSERTs are correctly detected and parsed.
In `@app-modules/profile/tests/Feature/ProfileCreationTest.php`:
- Around line 68-77: The test is relying on ordered tenant_id values which is
flaky with UUIDs; remove the explicit orderBy('tenant_id') on the
Profile::query() call and change the assertion that checks tenant IDs (the
expect(...)->toHaveCount(2) and ->and($profiles->pluck('tenant_id')->all())
portion) to assert membership regardless of order (e.g., compare as unordered
sets or use an assertion that canonicalizes/sorts both arrays) so the test
verifies the two tenant IDs are present without depending on their order.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Pro
Run ID: c1bc62ca-283d-42d9-bc68-ea5b7468afff
⛔ Files ignored due to path filters (1)
composer.lockis excluded by!**/*.lock
📒 Files selected for processing (15)
app-modules/profile/composer.jsonapp-modules/profile/database/factories/ProfileFactory.phpapp-modules/profile/database/migrations/2026_05_21_000000_create_user_profiles_table.phpapp-modules/profile/phpstan.ignore.neonapp-modules/profile/phpstan.neonapp-modules/profile/src/Enums/SeniorityLevel.phpapp-modules/profile/src/Enums/SocialPlatform.phpapp-modules/profile/src/Enums/StartAvailability.phpapp-modules/profile/src/Listeners/CreateProfileForTenantMember.phpapp-modules/profile/src/Models/Profile.phpapp-modules/profile/src/ProfileServiceProvider.phpapp-modules/profile/tests/Feature/ProfileCreationTest.phpapp-modules/profile/tests/Unit/ProfileEnumTest.phpapp-modules/profile/tests/Unit/ProfileSocialLinksTest.phpcomposer.json
BrunoSFreschi
left a comment
There was a problem hiding this comment.
Acho que bugo tudo aqui, não aparecem as alterações para mim!
danielhe4rt
left a comment
There was a problem hiding this comment.
Primo, obrigado pelo PR! Acho valido algumas coisas pra te ajudar na refatoração:
- Rode "php artisan boost:update" pra instalar as guidelines de Laravel no seu agent.
- use o
/laravel-best-practicespra te orientar no desenvolvimento.
Assim que terminar essas mudanças, mergeamos!
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app-modules/profile/tests/Unit/ProfileEnumTest.php`:
- Around line 18-22: The test currently only checks that
SeniorityLevel::Junior->getLabel(), ::Mid, ::Senior, ::Specialist, and ::Lead
return non-empty strings but doesn't verify translations resolved; update the
assertions to also assert each returned label is not equal to its translation
key (e.g., compare getLabel() != 'profile.seniority_level.junior' for Junior,
similarly for Mid, Senior, Specialist, Lead) so the test fails when the
translator returns the raw key; use the same enum case symbols
(SeniorityLevel::Junior->getLabel(), ::Mid->getLabel(), ::Senior->getLabel(),
::Specialist->getLabel(), ::Lead->getLabel()) to locate and modify the
assertions.
- Around line 48-53: The test "all seniority level cases have distinct colors
and icons" currently only checks counts; change it to verify uniqueness by
comparing the number of unique color and icon values to the number of
SeniorityLevel::cases(). For the arrays produced from SeniorityLevel::cases()
via getColor() and getIcon(), replace the simple count assertions with checks
that count(array_unique($colors)) === count(SeniorityLevel::cases()) and
count(array_unique($icons)) === count(SeniorityLevel::cases()) (or use the
collection unique() method and count()), so duplicate colors/icons will fail the
test.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Pro
Run ID: efa960cf-2b72-4dd2-9dbb-1252a4488d2e
⛔ Files ignored due to path filters (1)
composer.lockis excluded by!**/*.lock
📒 Files selected for processing (12)
app-modules/identity/src/Tenant/Concerns/InteractsWithTenants.phpapp-modules/identity/src/Tenant/Models/Tenant.phpapp-modules/identity/src/Tenant/Models/TenantUser.phpapp-modules/profile/lang/en/enums.phpapp-modules/profile/lang/pt_BR/enums.phpapp-modules/profile/src/Enums/SeniorityLevel.phpapp-modules/profile/src/Enums/SocialPlatform.phpapp-modules/profile/src/Enums/StartAvailability.phpapp-modules/profile/src/Observers/TenantUserObserver.phpapp-modules/profile/src/ProfileServiceProvider.phpapp-modules/profile/tests/Feature/ProfileCreationTest.phpapp-modules/profile/tests/Unit/ProfileEnumTest.php
✅ Files skipped from review due to trivial changes (3)
- app-modules/identity/src/Tenant/Models/TenantUser.php
- app-modules/profile/lang/en/enums.php
- app-modules/profile/lang/pt_BR/enums.php
…nd eager creation on tenant join
- Rename SeniorityLevel::Pleno to Mid with value 'mid' - Implement Filament enum interfaces (HasLabel, HasColor, HasIcon) on all profile enums following project conventions - Add i18n support with en/pt_BR translation files for enum labels - Replace hacky DB::listen SQL interception with proper TenantUser pivot model + Observer pattern for profile auto-creation - Remove CreateProfileForTenantMember listener (logic moved to observer) - Fix flaky UUID-ordering assertion in multi-tenant test - Update tests for new enum API and observer-based creation
- Add @Property annotations to TenantUser pivot for $user_id and $tenant_id - Suppress PHPStan return.type on Profile::socialLinks() set-only Attribute
…d table names Apply Rector rules: SignaturePropertyToSignatureAttributeRector, DescriptionPropertyToDescriptionAttributeRector, TablePropertyToTableAttributeRector
… ObservedBy attribute
Principais pontos:
Description
This PR introduces a new
he4rt/profilemodule providing tenant-scoped user profiles with automatic creation when users join tenants. It includes database migrations with UUID primary keys, Eloquent models with relationships and validation, enums for seniority levels and job availability, factories, comprehensive tests, and localized translations. The PR also refactors console commands across multiple modules to use PHP 8 attributes for metadata declarations, and relocates theTenantUserObserverto the identity module with proper observer registration.References
#272), Admin Panel (#206), Discord ETL (#205)#276)Dependencies & Requirements
he4rt/profile(>=1)filament/filament: ^5.6.4 → ^5.6.5filament/spatie-laravel-media-library-plugin: ^5.6.4 → ^5.6.5guzzlehttp/guzzle: ^7.10.3 → ^7.10.4driftingly/rector-laravel: ^2.3.0 → ^2.4.0 (dev)Contributor Summary
Changes Summary
app-modules/profile/composer.jsonapp-modules/profile/src/Models/Profile.phpapp-modules/profile/database/migrations/2026_05_21_000000_create_user_profiles_table.phpapp-modules/profile/database/factories/ProfileFactory.phpapp-modules/profile/src/Enums/SeniorityLevel.phpapp-modules/profile/src/Enums/SocialPlatform.phpapp-modules/profile/src/Enums/StartAvailability.phpapp-modules/profile/src/ProfileServiceProvider.phpapp-modules/profile/tests/Feature/ProfileCreationTest.phpapp-modules/profile/tests/Unit/ProfileEnumTest.phpapp-modules/profile/lang/en/enums.php,pt_BR/enums.phpapp-modules/identity/src/Tenant/Models/TenantUser.phpapp-modules/identity/src/Tenant/Observers/TenantUserObserver.phpcomposer.json