Laravel CRUD Generator is a simple command line tool to generate CRUD operations for your models.
app/
├── Http/
│ ├── Controllers/
│ │ └── Api/
│ │ └── {Model}Controller.php # RESTful controller
│ ├── Requests/
│ │ └── {Model}Request.php # Form request
│ ├── Resources/
| | └── {Model}Collection.php # JSON collection
│ │ └── {Model}Resource.php # JSON resource
├── Models/
│ └── {Model}.php # Model
└── Routes/
└── api.php # API route
composer require --dev onepkg/laravel-crud-generator
- Generate CRUD files for the users table:
php artisan onepkg:make-crud User
- If the table name is not in the plural form
php artisan onepkg:make-crud User --table=user
- Specify the routing file
php artisan onepkg:make-crud User --route=api
GET /api/users # get listing
POST /api/users # create
GET /api/users/{id} # show detail
PUT /api/users/{id} # update
DELETE /api/users/{id} # delete
- Publish the config file
php artisan vendor:publish --provider="Onepkg\LaravelCrudGenerator\LaravelCrudServiceProvider"
- Modify the configuration
You can modify the configuration in /config/crud - generator.php
[
'namespacedModel' => 'App\\Models',
'namespacedRequest' => 'App\\Http\\Requests\\Admin',
'namespacedResource' => 'App\\Http\\Resources\\Admin',
'namespacedController' => 'App\\Http\\Controllers\\Admin',
]
Publish the stubs
php artisan stub:publish
Modify the corresponding stubs in /stubs/*.
controller.crud.stub
model.crud.stub
request.crud.stub
resource-collection.crud.stub
resource.crud.stub
route.crud.stub