\'Model Required Fields\' package

王林
Release: 2024-07-27 20:58:23
Original
769 people have browsed it

With Model Required Fields package, you can get the required model fields, excluding primary keys, nullable fields, and fields with defaults.

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.

The above is the detailed content of \'Model Required Fields\' package. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template