Skip to content
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

[5.3] Allow chaining factory calls to define() and state() #16389

Merged
merged 1 commit into from
Nov 13, 2016

Conversation

shadoWalker89
Copy link
Contributor

This will allow to group each Model definitions

/**
 * Teacher
 */
$factory
    ->define(App\Teacher::class, function (Faker\Generator $faker)
    {
        return [
            //
        ];
    })
    ->state(App\Teacher::class, 'teacher_foo_state', function (Faker\Generator $faker) {
        return [
            //
        ];
    })
    ->state(App\Teacher::class, 'teacher_bar_state', function (Faker\Generator $faker) {
        return [
            //
        ];
    });

/**
 * Student
 */
$factory
    ->define(App\Student::class, function (Faker\Generator $faker)
    {
        return [
            //
        ];
    })
    ->state(App\Student::class, 'student_foo_state', function (Faker\Generator $faker) {
        return [
            //
        ];
    })
    ->state(App\Student::class, 'student_bar_state', function (Faker\Generator $faker) {
        return [
            //
        ];
    });

@taylorotwell taylorotwell merged commit a65af36 into laravel:5.3 Nov 13, 2016
@shadoWalker89 shadoWalker89 deleted the chain_model_factory branch November 14, 2016 07:37
ansidev pushed a commit to safestudio/mizu-core that referenced this pull request Nov 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants