thilagaraja/laravelcurdmvc

此包的最新版本(dev-master)没有可用的许可证信息。

dev-master 2023-03-25 17:12 UTC

This package is auto-updated.

Last update: 2024-09-25 20:15:59 UTC


README

Author

关于包的描述

  • 此包有助于开发人员轻松创建用于API集成的CRUD(创建、读取、更新、删除)。
  • 以下是使用此功能的命令。
composer require thilagaraja/laravelcurdmvc 
composer require intervention/image

系统需求

  • PHP
  • Laravel
  • MySQL

在 config/app.php 中添加以下内容

  • 在 provide 下
Thilagaraja\Laravelcurdmvc\LaravelCurdMvcProvider::class
  • 在 aliases 下
 'Input' => Illuminate\Support\Facades\Request::class,

需要禁用 csrf

  • App\Http\Middleware\VerifyCsrfToken.php
    protected $except = [
        'webhook/*', // Disable CSRF protection for routes matching the "webhook/*" pattern
    ];
  • 安装以下包以解决以下错误 => 类 'form' 未找到
composer require laravelcollective/html

CRUD 操作 API

步骤 1 : 模块创建主 API

{
  "module" : "module name here",
  "fields" : [
      {
        "column" : "email",
        "date_type" : "string",
        "required" : true,
        "unique" : true
      },
      {
        "column" : "image",
        "date_type" : "string"
      }
    ]
}


  • 数据类型 : 字符串、整数、日期、日期时间、大整数
  • 查看所有数据类型的 json 文件 示例有效载荷
  • 此包将在您的项目中创建一个主表,用于唯一模块验证。表名为 crud_master,用于图片上传的 avatar 表。
  • 如果您想在模块中添加图片列,您需要指定列名为 'image'。它将自动被视为文件上传。
  • 并且每个模块都有自己的表。

步骤 2 : 运行迁移以创建表

  • 在运行主模块 API 后,以下文件将自动创建在您的项目文件夹中
    • 迁移文件、控制器文件、模块文件和 web.php 文件中的路由。
    • 需要运行以下命令
    php artisan migrate
    
  • 目前我们只有创建表的迁移。如果您想修改表,您可以像平常一样手动更新迁移文件。

步骤 3 : 使用 API 端点