| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- use App\Commodity;
- use App\OwnerFeeDetail;
- use App\OwnerPriceOperation;
- use App\OwnerStoreFeeDetail;
- use App\StoreItem;
- use Illuminate\Database\Seeder;
- class OwnerStoreFeeDetailSeeder extends Seeder
- {
- /**
- * Run the database seeds.
- *
- * @return void
- */
- public function run()
- {
- //
- OwnerStoreFeeDetail::query()->truncate();
- StoreItem::query()->truncate();
- Commodity::query()->truncate();
- OwnerPriceOperation::query()->truncate();
- $owners = \App\Owner::query()->limit(10)->get();
- foreach ($owners as $owner) {
- $ownerPriceOperations = factory(\App\OwnerPriceOperation::class)->times(2)->create(['operation_type' => '出库']);
- foreach ($ownerPriceOperations as $operation) {
- $feeDetails = factory(OwnerFeeDetail::class)->times(100)->create(['owner_id' => $owner->id]);
- foreach ($feeDetails as $feeDetail) {
- factory(OwnerStoreFeeDetail::class)->create([
- 'owner_price_operation_id' => $operation->id,
- 'owner_id' => $owner->id,
- 'owner_fee_detail_id' => $feeDetail->id,
- ]);
- }
- }
- factory(StoreItem::class)->times(100)->create();
- factory(Commodity::class)->times(100)->create(['owner_id' => $owner->id]);
- }
- }
- }
|