After looking at this, it seems like the deadline should really be handled in the factory.
Having a bit of a time with the closure...
<?php
use Carbon\Carbon;
use Faker\Generator as Faker;
$deadline = $this->faker->numberBetween(1, 10);
$factory->define(App\Job::class, function (Faker $faker, $deadline) {
return [
'jobtitle' => $this->faker->sentence,
'body' => $this->faker->paragraph,
// 'deadline' => $this->faker->numberBetween(1, 10),
'deadline' => function () use ($deadline) {
return Carbon::now()
->addWeeks($deadline)
->toDateTimeString();
},
'user_id' => $this->faker->numberBetween(1, 1000),
'projectaddress' => $this->faker->streetAddress,
'city' => $this->faker->city,
'state' => $this->faker->state,
'zipcode' => $this->faker->postcode,
'biddertype' => $this->faker->word,
'job' => $this->faker->word,
'subjob' => $this->faker->word
];
});
The dd($job); in the test does not throw an error, but I can see the deadline does not addWeeks(). It seems to have added a day though!
#attributes: array:11 [
"jobtitle" => "Doloribus quisquam rerum quia rerum aut sint."
"body" => "Ullam recusandae odit quisquam ut minus harum ex. Delectus voluptas atque aut et vel mollitia quibusdam."
"deadline" => "2019-07-24 01:44:06"
"user_id" => 948
"projectaddress" => "5826 Antonietta Shores"
"city" => "South Clementine"
"state" => "Oklahoma"
"zipcode" => "17962"
"biddertype" => "est"
"job" => "suscipit"
"subjob" => "quia"