This generator reads your database schema files and generates CRUD-related files based on that. See below form more details.
This package is highly inspired by the nafiesl/SimpleCrudGenerator
package, which also provides a crud generator. However, that package creates simple stubs where all models are regarded as a set of two columns (name and description). Given this, it is still laborious to go back to each generated file (model, factory, tests, etc.) and change everything.
The package appzcoder/crud-generator
is more complete, in the sense that it produces migrations based on a schema. However, it misses factories and tests.
The main contribution of this package, therefore, is a artisan command that generates crud-related files. The idea that distinguishes this package from those other ones is that the command fetches the details of a given table to generate the following:
- a model
- a controller
- a form request for validation
- a factory
- a database seeder
- views to the regular CRUD actions
- a test file
- resource routes
If an of these files already exists, they are not overwritten.
The command php artisan autocrud:generate Customer
reads the information on table customers
and generates the following files:
app/Customer.php
: the eloquent modelapp/Http/Controllers/CustomerController.php
: the controller that converts requests into CRUD actionsapp/Http/Requests/Customer.php
: the form request file that validates user inputdatabase/factories/CustomerFactory.php
: the model factory fileresources/views/customer/{index,show,create,edit,_form}.blade.php
: the_form
view contains the form that is used both for the create and the edit actions.tests/Feature/ManageCustomersTest.php
: feature test class to test the high-level CRUD features
It also updates:
routes/web.php
to addcustomers
resource routedatabase/seeds/DatabaseSeeder.php
to call the generated seeders
$ composer require jdferreira/autocrud --dev