OwnerStoreOutFeeDetailSeeder.php 1.1 KB

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