1 month ago

What is the Laravel 8 replacement for factory->raw()

Posted 1 month ago by jjmeyer

In upgrading from Laravel 7 to Laravel 8, I changed out the legacy factory approach for the new factory. It was relatively painless however;

Previously I used

$attributes = factory(Profile::class)->raw();

to return an array bag of model attributes from the factory. It appears the raw() method is not supported in the redesigned factories.

$attributes = Profile::factory()->raw();

Call to undefined method Database\Factories\Profile\ProfileFactory::raw()

How would I return an array of fields from the factory as raw() did previously, instead of an instance of the Model as make() or create() does?

Please sign in or create an account to participate in this conversation.