承接 aesen/laravel-auto-request 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aesen/laravel-auto-request

最新稳定版本:v1.0.0

Composer 安装命令:

composer require aesen/laravel-auto-request

包简介

Automatically generate Laravel FormRequest classes from migrations

README 文档

README

Automatically generate Laravel FormRequest classes (Store & Update) directly from your database migrations.

This package helps you eliminate repetitive boilerplate by reading migration definitions and converting them into validation rules and messages.

✨ Features

  • Generate Store and Update FormRequest classes

  • Parse rules directly from migrations

  • Automatically detects:

    • required / nullable
    • string, text, boolean, integer
    • foreignIdexists
    • unique
  • Update requests automatically use sometimes

  • Configurable validation language (tr, en)

  • Customizable validation messages

  • Overwrite protection

  • Artisan command support

📦 Installation

composer require aesen/laravel-auto-request

Laravel will auto-discover the service provider.

⚙️ Configuration

Publish the config file:

php artisan vendor:publish --tag=auto-request-config

This will create:

config/auto-request.php

Available Options

return [
    'language' => 'tr',

    'rules' => [
        'store' => [
            'required' => true,
        ],
        'update' => [
            'use_sometimes' => true,
        ],
    ],

    'messages' => [
        'tr' => [
            'required' => ':attribute alanı zorunludur.',
            'unique'   => ':attribute daha önce kullanılmış.',
            'exists'   => ':attribute geçerli değil.',
        ],
        'en' => [
            'required' => ':attribute is required.',
            'unique'   => ':attribute has already been taken.',
            'exists'   => ':attribute is invalid.',
        ],
    ],
];

🚀 Usage

Generate both Store & Update requests:

php artisan make:auto-request Post

Generate only Store request:

php artisan make:auto-request Post --only=store

Generate only Update request:

php artisan make:auto-request Post --only=update

Generated files:

app/Http/Requests/Post/
├── StorePostRequest.php
└── UpdatePostRequest.php

🧠 How It Works

The package scans the model's create table migration and converts column definitions into validation rules.

Example Migration

$table->string('title')->unique();
$table->text('body');
$table->foreignId('category_id');
$table->boolean('active')->nullable();

Generated Rules (Store)

'title' => ['required', 'string', 'unique:posts,title'],
'body' => ['required', 'string'],
'category_id' => ['required', 'integer', 'exists:categories,id'],
'active' => ['nullable', 'boolean'],

Generated Rules (Update)

'title' => ['sometimes', 'string', 'unique:posts,title,$this->route("id")'],
'body' => ['sometimes', 'string'],
'category_id' => ['sometimes', 'integer', 'exists:categories,id'],
'active' => ['nullable', 'boolean'],

🌍 Validation Messages

Messages are generated automatically using the selected language.

Example (tr):

'title.required' => 'Title alanı zorunludur.',
'title.unique'   => 'Title daha önce kullanılmış.',

🛣 Roadmap

  • Index-based unique detection
  • Model fillable fallback
  • Attribute translations
  • Column comment parsing
  • Custom rule presets

🧑‍💻 Author

Abdullah Emin Esen GitHub: https://github.com/AbdullahEminEsen

📄 License

MIT License

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固