dkart/crud-maker

1.0.0 2023-06-16 21:32 UTC

This package is auto-updated.

Last update: 2024-10-01 00:14:52 UTC


README

安装

使用composer运行安装

composer require dkart/crud-maker

打开你的config/app.php并在提供者部分添加这一行

DKart\CrudMaker\CrudMakerServiceProvider::class,

运行artisan命令

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

你会得到这些文件

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

使用方法

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

例如,实体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

链接