-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add user language preference endpoint (#86) #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add preferred_locale column to users table (VARCHAR(5), nullable) - Add PATCH /v1/me/language endpoint with validation - Support for en (English) and de (German) locales - Allow null to reset preference to default - Update User model, factory, and AuthController - Add UpdateUserLanguageRequest with validation rules - Add 8 comprehensive feature tests (TDD approach) - Update CHANGELOG.md Fixes #86
💡 Tip: Consider Using Draft PRsBenefits of opening PRs as drafts initially:
How to convert:
This is just a friendly reminder - feel free to continue as is! 😊 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements user language preference functionality allowing users to set and persist their preferred UI language (English or German) via a new API endpoint. The implementation follows TDD principles with comprehensive test coverage.
Key Changes
- Database schema extended with
preferred_localecolumn in the users table - New PATCH endpoint
/v1/me/languagefor updating language preferences - Comprehensive validation ensuring only supported locales (
en,de, ornull) are accepted
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/Feature/Controllers/Api/V1/UserLanguagePreferenceTest.php |
Adds 8 comprehensive feature tests covering happy paths, validation, and authentication |
routes/api.php |
Registers new language preference endpoint in v1 API routes |
database/migrations/2025_11_16_192506_add_preferred_locale_to_users_table.php |
Adds nullable preferred_locale column to users table |
database/factories/UserFactory.php |
Updates factory to include preferred_locale with default null value |
app/Models/User.php |
Adds preferred_locale to fillable array and PHPDoc annotations |
app/Http/Requests/UpdateUserLanguageRequest.php |
Validates locale input using present, nullable, and Rule::in() |
app/Http/Controllers/AuthController.php |
Implements updateLanguage() method to handle language preference updates |
CHANGELOG.md |
Documents the new user language preference feature |
- Remove @return JsonResponse annotation (already in method signature) - Comply with no_superfluous_phpdoc_tags Pint rule - Match pattern used in sibling methods (logout, logoutAll, me) The return type is already declared in the method signature, making the PHPDoc @return tag redundant per PSR-12 standards.
Summary
Implements user language preference functionality to allow users to set their preferred UI language (English or German) in their profile.
Changes
Database
preferred_localecolumn touserstable (VARCHAR(5), nullable)2025_11_16_192506_add_preferred_locale_to_users_tableAPI
PATCH /v1/me/languageUpdateUserLanguageRequesten(English),de(German),null(reset to default)AuthController@updateLanguageModels
Usermodel withpreferred_localein fillableUserFactoryto includepreferred_localeTests
Testing
Acceptance Criteria (from #86)
preferred_localeadded to users tablePATCH /v1/me/languagecreateden,de, ornullacceptednull(reset preference)Documentation
Follow-up
Frontend implementation (#141) can now use this endpoint to persist user language preferences.
Closes #86