OwnerLogisticFeeDetailSeeder.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. use App\OwnerFeeDetail;
  3. use App\OwnerLogisticFeeDetail;
  4. use Carbon\Carbon;
  5. use Illuminate\Database\Seeder;
  6. class OwnerLogisticFeeDetailSeeder extends Seeder
  7. {
  8. /**
  9. * Run the database seeds.
  10. *
  11. * @return void
  12. */
  13. public function run()
  14. {
  15. // $ownerFeeDetails = OwnerFeeDetail::query()
  16. // ->with('items')
  17. // ->where('type', '发货')
  18. // ->where('outer_table_name', 'orders')
  19. // ->whereHas('logistic', function ($query) {
  20. // $query->where('type', '快递');
  21. // })
  22. // ->where('owner_id', [12])
  23. // ->where('worked_at', '>=', Carbon::parse('2021-05-30')->startOfDay())
  24. // ->where('worked_at', '<=', Carbon::parse('2021-05-31')->endOfDay())
  25. // ->get();
  26. // foreach ($ownerFeeDetails as $ownerFeeDetail) {
  27. // factory(\App\OwnerLogisticFeeDetail::class)->create([
  28. // 'owner_fee_detail_id' => $ownerFeeDetail->id,
  29. // 'logistic_bill' => $ownerFeeDetail->items->first()->logistic_bill??$ownerFeeDetail->logistic_bill,
  30. // 'logistic_id'=>$ownerFeeDetail->logistic_id,
  31. // 'province'=>$ownerFeeDetail->province
  32. // ]);
  33. // }
  34. // factory(\App\OwnerLogisticFeeDetail::class)->times(200)->create(
  35. // [
  36. // 'created_at' =>now()->subMonth()->startOfMonth()->addDays(1),
  37. // 'updated_at' => now()->subMonth()->startOfMonth()->addDays(2)
  38. // ]
  39. // );
  40. //
  41. // factory(\App\OwnerLogisticFeeDetail::class)->times(200)->create(
  42. // [
  43. // 'created_at' =>now()->subMonth()->startOfMonth()->addDays(2),
  44. // 'updated_at' => now()->subMonth()->startOfMonth()->addDays(3)
  45. // ]
  46. // );
  47. //
  48. // factory(\App\OwnerLogisticFeeDetail::class)->times(200)->create(
  49. // [
  50. // 'created_at' =>now()->subMonth()->startOfMonth()->addDays(3),
  51. // 'updated_at' => now()->subMonth()->startOfMonth()->addDays(4)
  52. // ]
  53. // );
  54. OwnerLogisticFeeDetail::query()->truncate();
  55. // OwnerFeeDetail::query()->truncate();
  56. $owners = \App\Owner::query()->limit(10)->get();
  57. foreach ($owners as $owner) {
  58. factory(OwnerLogisticFeeDetail::class)->times(200)->create([
  59. 'owner_id' => $owner->id,
  60. ]);
  61. }
  62. }
  63. }