OwnerStoreFeeDetailSeeder.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. use App\Commodity;
  3. use App\OwnerFeeDetail;
  4. use App\OwnerPriceOperation;
  5. use App\OwnerStoreFeeDetail;
  6. use App\StoreItem;
  7. use Illuminate\Database\Seeder;
  8. class OwnerStoreFeeDetailSeeder extends Seeder
  9. {
  10. /**
  11. * Run the database seeds.
  12. *
  13. * @return void
  14. */
  15. public function run()
  16. {
  17. //
  18. OwnerStoreFeeDetail::query()->truncate();
  19. StoreItem::query()->truncate();
  20. Commodity::query()->truncate();
  21. OwnerPriceOperation::query()->truncate();
  22. $owners = \App\Owner::query()->limit(10)->get();
  23. foreach ($owners as $owner) {
  24. $ownerPriceOperations = factory(\App\OwnerPriceOperation::class)->times(2)->create(['operation_type' => '出库']);
  25. foreach ($ownerPriceOperations as $operation) {
  26. $feeDetails = factory(OwnerFeeDetail::class)->times(100)->create(['owner_id' => $owner->id]);
  27. foreach ($feeDetails as $feeDetail) {
  28. factory(OwnerStoreFeeDetail::class)->create([
  29. 'owner_price_operation_id' => $operation->id,
  30. 'owner_id' => $owner->id,
  31. 'owner_fee_detail_id' => $feeDetail->id,
  32. ]);
  33. }
  34. }
  35. factory(StoreItem::class)->times(100)->create();
  36. factory(Commodity::class)->times(100)->create(['owner_id' => $owner->id]);
  37. }
  38. }
  39. }