This package will help you to create a model,migration,controller,request,resource just by writing the name.
You can install the package via composer:
composer require mohammad-najjary/laravel-entity-scaffoldThe default paths are set in config/entity-scaffold.php. Publish the config to copy the file to your own config:
php artisan vendor:publish --tag="entity-scaffold"php artisan make:entity your_entitySuppose our entity is a product:
php artisan make:entity productafter that,it make file in this paths:
Models:
App/Models/Product/Product.phpControllers:
App/Http/Controllers/ProductsController.phpForm Requests:
App/Requests/Product/StoreProduct.phpResources:
App/Resources/Product/ProductsResource.php
App/Resources/Product/ProductsCollection.phpMigrations:
****_**_**_******_create_products_tableBy entering the command below see options list:
php artisan make:entity --helpoutput:
Description:
Create (model,migration,controller,request,resource) for your entity.
Usage:
make:entity [options] [--] <entity>
Arguments:
entity Name of the entity
Options:
--con Ignore making the controller
--mod Ignore making the model
--mig Ignore making the migration
--res Ignore making the resource
--req Ignore making the request
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
All you have to do is use the first three letters of each class,eg:
I ignore migration for order entity
$ php artisan make:entity order --mig
--- Controller created successfully
--- Model created successfully
- - - Ignore making the migration
--- Request created successfully
--- Resource created successfully
Now i ignore all except migration
$ php artisan make:entity dart --req --res --con --mod
- - - Ignore making the controller
- - - Ignore making the model
--- Migration created successfully
- - - Ignore making the request
- - - Ignore making the resource
If you change default path.first see config/entity-scaffold.php file:
<?php
return [
/*
|--------------------------------------------------------------------------
| Controllers Path
|--------------------------------------------------------------------------
|
| Your controller path is located here App/Http/Controllers/{ENTITY_SCAFFOLD_CONTROLLER_PATH}
| example:
| ENTITY_SCAFFOLD_CONTROLLER_PATH='Admin/'
| Don't forget insert "/" to end of Your path.
*/
'controllers_path' => env('ENTITY_SCAFFOLD_CONTROLLER_PATH', '/'),
/*
|--------------------------------------------------------------------------
| Models Path
|--------------------------------------------------------------------------
|
| Your Models Path is located here App/{ENTITY_SCAFFOLD_MODEL_PATH}
|
*/
'models_path' => env('ENTITY_SCAFFOLD_MODEL_PATH', 'Models/'),
/*
|--------------------------------------------------------------------------
| Resource Path
|--------------------------------------------------------------------------
|
| Your Resource Path is located here App/Http/Resources/{ENTITY_SCAFFOLD_RESOURCE_PATH}
|
*/
'resources_path' => env('ENTITY_SCAFFOLD_RESOURCE_PATH', '/'),
/*
|--------------------------------------------------------------------------
| Requests Path
|--------------------------------------------------------------------------
|
| Your Requests Path is located here App/Http/Requests/{ENTITY_SCAFFOLD_REQUEST_PATH}
|
*/
'requests_path' => env('ENTITY_SCAFFOLD_REQUEST_PATH', '/'),
];And then change whatever path you want puts its key in .env file like this:
ENTITY_SCAFFOLD_CONTROLLER_PATH=Admin/Dashboard
ENTITY_SCAFFOLD_MODEL_PATH=EntityThe MIT License (MIT). Please see License File for more information.