This content originally appeared on DEV Community and was authored by Tefoh
Hi artisans, i created a package called Laravel scaffold command, adds an artisan command that you can generate necessary files for crud applications, either you use laravel as fullstack or a rest-api this can help you.
installation
composer require tefoh/laravel-scaffold-command
// then
php artisan vendor:publish --tag=scaffold-stubs
Thats it and just enter the model or entity you want crud operation with the fields needed. The fields is two parts, first is field name and second is field type this two separated with a colon. The field type must be from laravel migrations available column types, heres the link https://laravel.com/docs/8.x/migrations#available-column-types. For example to create a crud operation for Category enter this:
php artisan scaffold Category --fields=name:string,slug:string,parent_id:foreignId
And for rest-api just add api parameter to create necessary resources instead of views. And controller will be a bit different:
php artisan scaffold Tag --api --fields=name:string,slug:string,parent_id:foreignId
The original idea comes from ruby on rails, they have a similar command. The beauty of this package is you can use laravel stubs and fully customize how controllers and views created when you enter this command. I hope this will be helpful for you :)
This content originally appeared on DEV Community and was authored by Tefoh
Tefoh | Sciencx (2021-10-02T20:30:38+00:00) Laravel scaffold command. Retrieved from https://www.scien.cx/2021/10/02/laravel-scaffold-command/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.