DEV Community

Cover image for Laravel CRUD Generator
Mehrad Sadeghi
Mehrad Sadeghi

Posted on • Edited on • Originally published at mehradsadeghi.com

Laravel CRUD Generator

Laravel CRUD Generator is a simple and light-weight wrapper on Laravel's default controller generator, Which makes creating a controller with a pre-defined CRUD like a breeze.

You can define your validation rules in an interactive way that crud-generator provides. Also it is compatible with Laravel 5.x, 6.x, 7.x, 8.x and 9.x.

There is demo available here which is showing how it's done :)

Installation

$ composer require mehradsadeghi/laravel-crud-generator

Usage

It works based on your $fillable property of the target model.

If you would like to use $guarded instead of $fillable, It is supported too. In that case you'll need to have an existing Schema (table), Then the crud generator will automatically figures out your fillables.

As an example:

$ php artisan make:crud UserController --model=User

If you would like to have validaiton rules too, You may enter the --validation option:

$ php artisan make:crud UserController --model=User --validation

Customizing Default Stubs

It is possible to publish default stubs and change them in a way that fulfills your requirements.

In order to do this:

$ php artisan crud:publish

The published stubs will be located within stubs/crud directory in the root of your application. Any changes you make to these stubs will be reflected when you generate crud.

Feel free to take a look at crud-generator repository.

Top comments (4)

Collapse
 
msamgan profile image
Mohammed Samgan Khan

Nice man, you made life a bit easier...

Collapse
 
mehradsadeghi profile image
Mehrad Sadeghi

Thanks for your kind words :)

Collapse
 
damirmount profile image
damirMount

The "requests" option does not exist. (

Collapse
 
mehradsadeghi profile image
Mehrad Sadeghi

Fixed.