forked from crater-invoice-inc/crater
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEstimateItemFactory.php
34 lines (31 loc) · 1.01 KB
/
EstimateItemFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use Crater\EstimateItem;
use Crater\Item;
use Faker\Generator as Faker;
use Crater\User;
$factory->define(EstimateItem::class, function (Faker $faker) {
return [
'item_id' => function () {
return factory(Item::class)->create()->id;
},
'name' => function (array $item) {
return Item::find($item['item_id'])->name;
},
'description' => function (array $item) {
return Item::find($item['item_id'])->description;
},
'price' => function (array $item) {
return Item::find($item['item_id'])->price;
},
'quantity' => $faker->randomDigitNotNull,
'company_id' => User::find(1)->company_id,
'discount_type' => 'fixed',
'tax' => $faker->randomDigitNotNull,
'discount_val' => 0,
'total' => function (array $item) {
return ($item['price'] * $item['quantity']);
},
'discount' => 0
];
});