Skip to content

Conversation

@nunomaduro
Copy link
Member

@nunomaduro nunomaduro commented Oct 22, 2021

At this time, database factories have this hidden feature where database models can be "guessed". As example, the following code just works:

class User extends Model
{
    use HasFactory;
}

class UserFactory extends Factory
{
    public function definition()
    {
        return [
            // ..
        ];
    }
}

User::factory()->create(); // Guesses UserFactory
UserFactory::new()->create(); // Guesses User

So, this pull request proposes that remove protected $model from the Factory stub, as probably the current "guess" logic works for 99.99% of the people. In addition, I've also pull requested to the skeleton that we remove protected $model = User::class from the UserFactory.php: laravel/laravel#5713.

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.

4 participants