Laravel 8 introduced new class based model factories and if you have an existing project you can use the legacy factories package to keep using the old factories. I have tended to keep the factories as they were and continue development, but after working on a fresh Laravel 8 project and using the new class based syntax I decided to go back and update the factories in the older Laravel apps. This article explains how I went about refactoring the factories to classes.

In this scenario we have a Laravel app that allows you to create a post. The post has a title, content, author and is either published or not published.

#php #laravel

How to Refactor Laravel Factories to Laravel 8 Class Model Factories
23.20 GEEK