4 changed files with 51 additions and 25 deletions
-
6app/Entities/Projects/Project.php
-
24database/factories/ModelFactory.php
-
30database/factories/ProjectFactory.php
-
16tests/Unit/Models/ProjectTest.php
@ -0,0 +1,30 @@ |
|||
<?php |
|||
|
|||
use App\Entities\Agencies\Agency; |
|||
use App\Entities\Partners\Partner; |
|||
use App\Entities\Projects\Project; |
|||
use Faker\Generator as Faker; |
|||
|
|||
$factory->define(Project::class, function (Faker $faker) { |
|||
|
|||
$proposalDate = $faker->dateTimeBetween('-1 year', '-1 month')->format('Y-m-d'); |
|||
$startDate = Carbon::parse($proposalDate)->addDays(10); |
|||
$endDate = $startDate->addDays(rand(1, 13) * 7); |
|||
|
|||
return [ |
|||
'name' => $faker->sentence(3), |
|||
'description' => $faker->paragraph, |
|||
'proposal_date' => $proposalDate, |
|||
'start_date' => $startDate->format('Y-m-d'), |
|||
'end_date' => $endDate->format('Y-m-d'), |
|||
'project_value' => $projectValue = rand(1, 10) * 500000, |
|||
'proposal_value' => $projectValue, |
|||
'status_id' => rand(1, 6), |
|||
'owner_id' => function () { |
|||
return factory(Agency::class)->create()->id; |
|||
}, |
|||
'customer_id' => function () { |
|||
return factory(Partner::class)->create()->id; |
|||
}, |
|||
]; |
|||
}); |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue