vendredi 29 janvier 2016

Laravel php's date_add function don't work

Made this Laravel seeder function. Problem is the dates dosen't change as expected. If I run the code in Tinker it works.

What am I doing wrong?

public function run() { $faker = Faker::create();

foreach(range(1, 10) as $index)
{
    $myDateCalled = $faker->dateTime($max = 'now');

    $myDateAllocated = $myDateCalled;
    $i = $faker->numberBetween($min = 5, $max = 300);
    date_add($myDateAllocated, date_interval_create_from_date_string("{$i} seconds"));

    $myDatePickedUp = $myDateAllocated;
    $i = $faker->numberBetween($min = 5, $max = 30);
    date_add($myDatePickedUp, date_interval_create_from_date_string("{$i} minutes"));

    $myDateDelivered = $myDatePickedUp;
    $i = $faker->numberBetween($min = 10, $max = 90);
    date_add($myDateDelivered, date_interval_create_from_date_string("{$i} minutes"));


    dd($myDateCalled, $myDateAllocated, $myDatePickedUp, $myDateDelivered);

    Hhtransport::create([
        'Called' => $myDateCalled,
        'Allocated' => $myDateAllocated,
        'PickedUp' => $myDatePickedUp,
        'Delivered' => $myDateDelivered,
        'From' => $faker->numberBetween($min = 1, $max = 99),
        'To' => $faker->numberBetween($min = 1, $max = 99),
        'Put' => $faker->numberBetween($min = 1, $max = 99),
        'Drev' => $faker->numberBetween($min = 1, $max = 99),
        'Container' => $faker->numberBetween($min = 1, $max = 99)
    ]);
}

}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1m0duuq
via IFTTT

Aucun commentaire:

Enregistrer un commentaire