feat(users): split name into first and last fields#33
Conversation
There was a problem hiding this comment.
Pull request overview
Introduces a split-name data model for users by replacing the single name field with first_name and last_name, while providing computed name and initials accessors on the User model.
Changes:
- Updates the users schema and seed data to use
first_name/last_name. - Adds
nameandinitialscomputed attributes (andnamereverse assignment) onApp\Models\User. - Adds Pest feature tests covering name composition, splitting, and initials derivation.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
database/migrations/0001_01_01_000000_create_users_table.php |
Replaces name column with first_name/last_name in the users table schema. |
app/Models/User.php |
Updates fillable fields and adds computed name + initials attributes via accessors. |
database/factories/UserFactory.php |
Generates first_name/last_name from Faker output instead of a single name. |
database/seeders/DatabaseSeeder.php |
Seeds the test user using the new name fields. |
tests/Feature/UserNameAttributesTest.php |
Adds feature coverage for the new computed/derived user name behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $table->string('first_name'); | ||
| $table->string('last_name'); |
There was a problem hiding this comment.
This PR updates the initial users migration in-place (replacing the existing name column with first_name/last_name). If anyone has already run the original migration, php artisan migrate will not apply this change, leaving their DB schema out of sync and causing runtime/test failures. Prefer adding a new migration that adds first_name/last_name, backfills from name, then drops name (or clearly document that contributors must migrate:fresh).
| $table->string('first_name'); | |
| $table->string('last_name'); | |
| $table->string('name'); |
| it('combines the user name fields into a name attribute', function (): void { | ||
| $user = User::factory()->create([ |
There was a problem hiding this comment.
The PR description says it closes #7, but the linked Issue #7 is about installing/wiring Laravel Fortify authentication flows, while this PR changes user name fields and related model accessors/tests. Please update the issue reference (or PR title/description) so the PR is linked to the correct work item.
Closes #7\n\nSummary:\n- Replaces the initial users table column with and \n- Adds computed and attributes on the User model\n- Updates the factory and seed data to use the new name shape\n- Adds Pest coverage for name composition, reverse assignment, and initials\n\nValidation:\n- vendor/bin/pint --dirty --format agent\n- php artisan test --compact\n- npm run build