I first needed this information while working on a large project with no tests or factories and many migrations. It was distracting to manually look for each required field.
I created a simple trait to fetch required fields. It was easy in Laravel 11 and 10. Then I realized that most programmers who face this problem are usually using older versions, so I added support for Laravel 9, 8, 7, and 6, and extracted the logic into a package.
I tested the code for each supported Laravel version and each SQL database: SQLite, MySQL, MariaDB, PostgreSQL, and Microsoft SQL Server. I needed to add support for each SQL database because I used the DB facade with raw SQL queries, and there were slight differences each time.
The package is fully tested with PHPUnit and GitHub Actions for every Laravel version and for each database.
The usage and examples are in the readme file.
I hope you like this package, and I welcome any contributions or comments.
package link:
https://github.com/watheqAlshowaiter/model-required-fields. submitted by /u/watheq_show
[link] [comments]
0 comments:
Post a Comment
Thanks