truncate(); // OwnerStoragePriceModel::query()->truncate(); $owners = \App\Owner::query()->get(); foreach ($owners as $owner) { $priceModels = factory(OwnerStoragePriceModel::class)->times(2)->create(); foreach ($priceModels as $priceModel) { factory(OwnerAreaReport::class)->create([ 'user_owner_group_id' => random_int(1, 100), 'owner_id' => $owner->id, 'counting_month' => now()->subMonth()->startOfMonth()->toDateString(), 'owner_storage_price_model_id' => $priceModel->id ]); } } } }