mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 04:01:10 -04:00
init crater
This commit is contained in:
34
database/factories/InvoiceItemFactory.php
Normal file
34
database/factories/InvoiceItemFactory.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Laraspace\InvoiceItem;
|
||||
use Laraspace\Item;
|
||||
use Faker\Generator as Faker;
|
||||
use Laraspace\User;
|
||||
|
||||
$factory->define(InvoiceItem::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;
|
||||
},
|
||||
'company_id' => User::find(1)->company_id,
|
||||
'quantity' => $faker->randomDigitNotNull,
|
||||
'discount_type' => 'fixed',
|
||||
'discount_val' => 0,
|
||||
'tax' => $faker->randomDigitNotNull,
|
||||
'total' => function (array $item) {
|
||||
return ($item['price'] * $item['quantity']);
|
||||
},
|
||||
'discount' => 0
|
||||
];
|
||||
});
|
||||
Reference in New Issue
Block a user