public function seed()
    {
        $this->addLastModel();

        $insertedPKs = [];

        foreach ($this->quantities as $modelClass => $quantity) {
            $attributes = [];
            $pivotRecords = [];
            $translations = [];

            $this->modelPopulators[$modelClass]->setGuessedColumnFormatters(true);

            for ($i = 0; $i < $quantity; $i++) {
                list($createdModel, $pivotTables, $currentPivotRecords, $foreignKeys) =
                    $this->modelPopulators[$modelClass]->getInsertRecords($insertedPKs);

                // If the primary key is not auto incremented, it will be among the inserted attributes.
                if ($primaryKey = $createdModel->getKey()) {
                    $insertedPKs[$modelClass][] = $primaryKey;
                }

                $attributes[] = $createdModel->getAttributes();

                if ($currentPivotRecords) {
                    $pivotRecords[] = $currentPivotRecords;
                }

                if ($createdModel->relationLoaded('translations')) {
                    // We're not gonna use \Illuminate\Support\Collection::toArray(), because the
                    // translation model could have accessors to append to its array form.
                    foreach ($createdModel->translations as $translation) {
                        $translations[$i][] = $translation->getAttributes();
                    }
                }
            }

            // SQL limits how many rows you can insert at once, so we'll chunk the records.
            foreach (array_chunk($attributes, 500) as $chunk) {
                $createdModel->insert($chunk);
            }

            if (!isset($insertedPKs[$modelClass])) {
                $insertedPKs[$modelClass] = $this->getInsertedPKs($createdModel, count($attributes));
            }

            $this->insertPivotRecords(
                $createdModel->getConnection(),
                $pivotTables,
                $pivotRecords,
                $foreignKeys,
                $insertedPKs[$modelClass]
            );

            $this->insertTranslations($createdModel, $translations, $insertedPKs[$modelClass]);
        }

        $this->forgetAddedModels();

        $this->closeDoctrineConnections();

        return $insertedPKs;
    }