Giter Club home page Giter Club logo

Comments (5)

gbrock avatar gbrock commented on July 28, 2024

I ran into this too. The problem lies in the fact that the way you're declaring the variable TestDummy uses to generate is not the data itself, but rather a quick means to tell TestDummy how it should generate the data.

In order to manipulate each date directly, you need to use a closure. From the docs (example modified):

Alternatively, you may pass a closure as the second argument to the $factory method. This can be useful for situations where you need a bit more control over the values that you assign to each attribute. Here's an example:

$factory('App\MyModel', function($faker, $overrides) {
    $date = $faker->dateTimeBetween('-1 days','+1 months')->format('Y-m-d');

    return [
        'date' => $date
    ];
});

from testdummy.

swekaj avatar swekaj commented on July 28, 2024

Note, the closure doesn't accept an $overrides argument. It only accepts the $faker instance.

from testdummy.

mikeritter avatar mikeritter commented on July 28, 2024

Thanks for that @gbrock . This produces a date that's the same in all entries.

from testdummy.

gbrock avatar gbrock commented on July 28, 2024

There seems to be a bug in defining closures introduced recently, covered in this issue. You could load the last working version in your composer.json:

        "laracasts/testdummy": "2.1",

...which works for the time being (thanks @h-collector).

from testdummy.

alariva avatar alariva commented on July 28, 2024

I had the same problem and #86 helped out.

Example here

from testdummy.

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.