Fabricator example

/** * Creates a single item using Fabricator. * * @param Model|object|string $model Instance or name of the model * @param array|null $overrides Overriding data to pass to Fabricator::setOverrides() * @param bool $persist * * @return array|object */
    function fake($model, ?array $overrides = null, $persist = true)
    {
        $fabricator = new Fabricator($model);

        if ($overrides) {
            $fabricator->setOverrides($overrides);
        }

        if ($persist) {
            return $fabricator->create();
        }

        return $fabricator->make();
    }
}
Home | Imprint | This part of the site doesn't use cookies.