intentsolutions/make-crud

laravel 的 CRUD 制作工具

dev-main 2024-07-22 13:06 UTC

This package is not auto-updated.

Last update: 2024-10-01 12:19:52 UTC


README

安装

使用 composer 运行安装

composer require intentsolutions/make-crud

打开你的 config/app.php 文件并在 providers 部分添加以下行

IS\CrudMaker\CrudMakerServiceProvider::class,

运行 artisan 命令

php artisan vendor:publish --provider="IS\CrudMaker\CrudMakerServiceProvider"

你会得到以下文件

app
└──  Filters
   ├── BaseFilters.php
   └── Filterable.php

用法

CRUD 字段基于数据库中的表。

例如,Product 实体的字段将根据数据库中的 products 表生成

php artisan make:crud

之后,你需要输入实体名称并选择一个模板

模板

Api

在创建 CRUD 时,你会得到以下结构

如果你想使用 Swagger/OpenApi,你还应该安装这个包 https://github.com/DarkaOnLine/L5-Swagger 并在 Controller.php 中填写 @OA\Info

app
├── Http
│   ├── Controllers
│   │   └── EntityController.php
│   ├── Requests
│   │   └── Entity
│   │       └── EntityRequest.php
│   └── Resources
│       └── Entity
│           ├── EntityCollection.php
│           └── EntityResource.php
├── Models
│   ├── Entity.php
├── Repositories
│   └── EntityRepository.php
└── Services
  └── EntityService.php
database
└── factories
   └── EntityFactory.php
tests
└── Feature
   └── EntityTest.php

默认

在创建 CRUD 时,你会得到以下结构

app
├── Http
│   ├── Controllers
│   │   └── EntityController.php
│   └── Requests
│       └── Entity
│           └── EntityRequest.php
├── Models
│   └── Entity.php
├── Repositories
│   └── EntityRepository.php
└── Services
  └── EntityService.php
database
└── factories
   └── EntityFactory.php
resources
└── views
  └── entity
      ├── form.blade.php
      ├── list.blade.php
      └── show.blade.php
tests
└── Feature
   └── EntityTest.php

链接