I love Laravel factories, I use them in tests and that's why my definition includes some faker arguments eg:
public function definition()
{
return [
"post_title" => fake()->title(),
"post_content" => fake()->randomHtml(),
"post_excerpt" => fake()->paragraph(1),
];
}
But I also like to use factories inside my controllers, (I don't use factories with eloquent I have some custom implementation on them so it does make sense to use in it controllers too).
The only issue is what if I don't want to use post_excerpt for instance? if I don't provide it in will use fake()->paragraph(1) which is obviously not what I need, is there any way that you can ignore the definition altogether while using a factory, or just remove a few fields from it?
I know I can just add post_excerpt part with a state but that means I'll have a lot more states just to make this work, another way might be that I provide null as an override, but I'm looking for a cleaner way. (if it does exist)