PHPackages                             moh4mmad/request-validation-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. moh4mmad/request-validation-generator

ActiveLibrary[Database &amp; ORM](/categories/database)

moh4mmad/request-validation-generator
=====================================

A package to generate request validation files based on migration column data types, column lengths, uniqueness, and foreign keys.

v1.0.2(2y ago)035MITPHPPHP ^7.4|^8.0

Since May 22Pushed 2y ago1 watchersCompare

[ Source](https://github.com/moh4mmad/request-validation-generator)[ Packagist](https://packagist.org/packages/moh4mmad/request-validation-generator)[ RSS](/packages/moh4mmad-request-validation-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

Request Validation Generator
============================

[](#request-validation-generator)

Request Validation Generator is a Laravel package that automatically generates request validation files based on your migration column data types, column lengths, uniqueness, and foreign keys.

Installation
------------

[](#installation)

You can install the package via Composer. Run the following command:

```
composer require moh4mmad/request-validation-generator
```

After installing the package, you need to publish the configuration file and migration files. Run the following command to publish the package assets:

```
php artisan vendor:publish --tag=request-validations
```

This command will publish the package's configuration file and migration files to your application, allowing you to customize the behavior and modify the generated request validation files if needed.

Usage
-----

[](#usage)

To generate request validation files for your migrations, run the following Artisan command:

```
php artisan generate:request-validations
```

The command will scan your migration files and generate request validation files based on the column data types, lengths, uniqueness, and foreign keys. The generated files will be placed in the `app/Http/Requests` directory.

### Example

[](#example)

Let's say you have a migration file `20220101000000_create_users_table.php` with the following columns:

```
Schema::create('users', function (Blueprint $table) {
    $table->id();
    $table->string('name');
    $table->string('email')->unique();
    $table->timestamp('email_verified_at')->nullable();
    $table->string('password');
    $table->timestamps();
});
```

Running the `generate:request-validations` command will generate a request validation file `app/Http/Requests/User/Request.php` with the following content:

```
