noouh/auto-model-fillable 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

noouh/auto-model-fillable

最新稳定版本:v2

Composer 安装命令:

composer require noouh/auto-model-fillable

包简介

A Laravel package to auto-generate Fillable to models from table definitions.

README 文档

README

A Laravel package to auto-generate fillable properties for models based on table definitions from a JSON file.

Installation

You can install the package via composer:

composer require noouh/auto-model-fillable

Usage

To generate fillable properties for all models based on table definitions from a JSON file, use the following command:

php artisan noouh:generate-fillable path/to/your/json/file.json

Example JSON File

The JSON file should contain the table definitions with the columns. Here is an example structure:

[
  {
    "table": "users",
    "columns": [
      {
        "name": "id",
        "type": "int",
        "primaryKey": true,
        "autoIncrement": true
      },
      { "name": "name", "type": "string" },
      { "name": "email", "type": "string" }
    ]
  },
  {
    "table": "posts",
    "columns": [
      {
        "name": "id",
        "type": "int",
        "primaryKey": true,
        "autoIncrement": true
      },
      { "name": "title", "type": "string" },
      { "name": "content", "type": "text" },
      { "name": "user_id", "type": "unsignedBigInteger" }
    ],
    "relationships": [
      { "type": "belongsTo", "relatedTable": "users", "foreignKey": "user_id" }
    ]
  }
]

How It Works

  1. Loop Through Model Files: The script loops through all model files in the app/Models directory.
  2. Extract Table Name: It extracts the table name from each model file using the $table property.
  3. Get Columns from JSON: It retrieves the columns for the corresponding table from the provided JSON file.
  4. Update Fillable Properties: It updates the model file with the fillable properties if the table and columns are found.

About the Company

Noouh For Integrated Solutions is dedicated to providing innovative software solutions. We specialize in developing high-quality applications tailored to meet the specific needs of our clients.

Email: info@noouh.com

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-22