macropay-solutions/laravel-crud-wizard-generator

Library for laravel-crud-wizard class generation

1.2.1 2025-04-01 17:37 UTC

This package is not auto-updated.

Last update: 2025-04-01 17:49:40 UTC


README

Total Downloads Latest Stable Version License

Library for laravel-crud-wizard-free - laravel-crud-wizard and for laravel-crud-wizard-decorator-free - laravel-crud-wizard-decorator

Installation

1. Run composer command:

composer require macropay-solutions/laravel-crud-wizard-generator --dev

2. Publish the provider:

php artisan vendor:publish --provider="MacropaySolutions\LaravelCrudWizardGenerator\LaravelCrudWizardGeneratorServiceProvider"

Usage

php artisan make:api-resource {resourceName} {--decorated} {--table=} {--connection=}

This will create a template for controller, service and model (with prepopulated columns from DB) (optionally, with the --decorated flag it will create also a decorator and middleware) and will print instructions on what is left to be done manually.

If connection is not the default one, it can be specified in the command option.

If table is not the plural snake cased resourceName, then it can be specified in the table option.

Run just php artisan make:api-resource for interactive mode that will try to guess the tableName and use default connectionName (except --decorated).

Example:

# php artisan make:api-resource operations
Created Model: /var/www/html/project/app/Models/Operation.php
Created Service: /var/www/html/project/app/Services/OperationsService.php
Created Controller: /var/www/html/project/app/Http/Controllers/OperationsController.php
TODO:
- Create migration if needed,
- Fill the model's properties and relations,
- Define validations in controller,
- Expose resource in DbCrudMap::MODEL_FQN_TO_CONTROLLER_MAP.
Created Decorator: /var/www/html/project/app/Decorators/OperationDecorator.php
Created Middleware: /var/www/html/project/app/Http/Midleware/Decorators/OperationsMiddleware.php
# php artisan make:api-resource operations --decorated
Created Model: /var/www/html/project/app/Models/Operation.php
Created Service: /var/www/html/project/app/Services/OperationsService.php
Created Controller: /var/www/html/project/app/Http/Controllers/OperationsController.php
TODO:
- Create migration if needed,
- Fill the model's properties and relations,
- Define validations in controller,
- Expose resource in DbCrudMap::MODEL_FQN_TO_CONTROLLER_MAP.
Created Decorator: /var/www/html/project/app/Decorators/OperationDecorator.php
Created Middleware: /var/www/html/project/app/Http/Midleware/Decorators/OperationsMiddleware.php
TODO:
- Fill the decorator,
- Register middleware decorator as route middleware,
- Use the middleware alias as middleware in your crud route definition for each method.

Note.

If errors appear for creating folders, create the folders manually and run again the command.

If the command was already ran without the --decorated flag, it can be run again with it to generate the decorator and middleware.

License

This package is licensed under the license MIT.