Skip to content

[PROPOSAL] State support for entity Factory #199

@jakub-klapka

Description

@jakub-klapka

Hello,
with laravel/framework 5.3.17, they have added states to model factories. It would be nice to have this adopted in orm, since it is similar to defineAs functionality. States would be just more familiar to Laravel users and they have one advantage compared to defineAs - you can stack them up.

States are described here: https://laravel.com/docs/5.3/database-testing#writing-factories
The main difference from yours defineAs is, that with states, you define only those properties, which are different from those in base factory and you can define multiple states. Then, when you are calling factory()->states(['one','two']) it would merge all state properties on top of base factory properties.

I think, that this is really neat, since you can combine those in many different ways. With defineAs, you don't have that much flexibility.

Thanks for considering this ;-)
Jakub

Related to quick-fix #198

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions