[3.x] allow modification of the personal team using an optional callable#1278
Merged
taylorotwell merged 3 commits intolaravel:3.xfrom Mar 13, 2023
Merged
Conversation
I want this in jetstream projects, and it feels like something others would also want. It helps to set up the seeder in a Laravel Jetstream Project quickly.
For example:
```php
User::factory()->withPersonalTeam(
fn (TeamFactory $factory) => $factory
->state([
'foo' => 'bar',
])
->has(
Post::factory()
->count(10)
)
)
->create();
```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
withPersonalTeammethod, now has a callable parameter that will apply to the factory.Why
Allows for modification of the withPersonalTeam method so that a callable can be passed to the method to modify the team factory further, for example:
I find myself wanting this out of the box when I use Jetstream, and others would appreciate the ability to do it without copying it to their project every time. Equally, it doesn't break any compatibility.