Giter VIP home page Giter VIP logo

Comments (3)

codeitlikemiley avatar codeitlikemiley commented on August 24, 2024

I found out that using an array syntax when defining factory , causes this error
for example:

this syntax is ok with laravel, if you are not passing any Faker in the function

this is the short syntax but for some reason your Generatecommand throw error in this?

why? you should also accept this syntax...

$factory->state(User::class, 'payment', [
        'payment' => [
            'name'   => 'BDO',
            'amount' => 12000,
            'paid'   => true
        ]
    ]);

after changing to this syntax error goes away


$factory->state(User::class, 'payment', function () {
    return [
        'payment' => [
            'name'   => 'BDO',
            'amount' => 12000,
            'paid'   => true
        ]
    ];
});

from laravel-factories-reloaded.

christophrumpel avatar christophrumpel commented on August 24, 2024

Thanks @codeitlikemiley. We had this on our list. Let me check that.

from laravel-factories-reloaded.

christophrumpel avatar christophrumpel commented on August 24, 2024

@nuernbergerA and me took a look you are right. The array syntax is not supported currently. I change the code so it throws now a new exception with a helpful message about it.

It is quite some amount of work to make arrays work too, so we won't focus on supporting that right now. But we will at some point in the future. Please use the closure syntax for now.

from laravel-factories-reloaded.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.