forFabricatorCreateFailed example

$ids = [];

        // Iterate over new entities and insert each one, storing insert IDs         foreach ($this->make($count ?? 1) as $result) {
            if ($id = $this->model->insert($result, true)) {
                $ids[] = $id;
                self::upCount($this->model->table);

                continue;
            }

            throw FrameworkException::forFabricatorCreateFailed($this->model->table, implode(' ', $this->model->errors() ?? []));
        }

        // If the model defines a "withDeleted" method for handling soft deletes then use it         if (method_exists($this->model, 'withDeleted')) {
            $this->model->withDeleted();
        }

        return $this->model->find($count === null ? reset($ids) : $ids);
    }

    /** * Generate new database entities without actually inserting them * * @param int|null $count Optional number to create a collection * * @return array|object An array or object (based on returnType), or an array of returnTypes */
Home | Imprint | This part of the site doesn't use cookies.