I have always thought of Laravel factories as a 'development' aid for generating fake data for testing purposes.
Recently, I inherited a Laravel 8 project where this is used in part for that, but it is also called from the production code to essentially insert 'default data' for a new entity that is being created.
(Think: We're creating a Company::class, and so we're going to also create blank contact profiles (CompanyContact::class) for its 'president', 'vice-president', and 'treasurer' with some basic placeholder text.)
That obviously works but when trying to determine where this default data was even coming from, it never occurred to me to look in database seeders/factories.
I would rather have expected to see a "created" event responder, either setup in Model::boot() or as a standalone event.
Aside from confusing future developers (or just me?), are there any other gotchas to using (misusing?) factory methods as a means of setting up 'default data'?
I got used to seeding the website settings or even some default data like Countries by using Seeders.
Of course, triggering events when seeding these data will be a good solution, but also I think the simple solution is leaving the created_at column null to determine the source of the data.