PHPackages                             matheus-carvalho/crud-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. matheus-carvalho/crud-generator

ActiveLibrary[Framework](/categories/framework)

matheus-carvalho/crud-generator
===============================

Generate a CRUD with Model, Controller, routes, FormRequest and views based on given Migration.

v1.1.0(4y ago)231415MITPHP

Since Jan 13Pushed 4y agoCompare

[ Source](https://github.com/matheus-carvalho/crud-generator)[ Packagist](https://packagist.org/packages/matheus-carvalho/crud-generator)[ RSS](/packages/matheus-carvalho-crud-generator/feed)WikiDiscussions master Synced today

READMEChangelog (3)DependenciesVersions (4)Used By (0)

CRUD GENERATOR for Laravel
==========================

[](#crud-generator-for-laravel)

Crud Generator provides a complete experience of develop an entire CRUD only writing the migration file.

### Installing via Composer

[](#installing-via-composer)

```
composer require matheus-carvalho/crud-generator
```

### Publish the CSS and Config folder

[](#publish-the-css-and-config-folder)

```
php artisan vendor:publish
```

Usage
-----

[](#usage)

1. Create your migration and fill up the fields.
2. Open a cmd on project root and type:

```
php artisan generate:crud table_name ResourceName
```

Simple example
==============

[](#simple-example)

1. Creating the migration.

```
php artisan make:migration create_categories_table
```

2. Filling up the migration.

```
public function up()
{
    Schema::create('categories', function (Blueprint $table) {
        $table->id();

        $table->string('name');
        $table->text('description')->nullable();

        $table->timestamps();
    });
}
```

3. Generating the CRUD.

```
php artisan generate:crud categories Category
```

Available column types example
------------------------------

[](#available-column-types-example)

1. Creating the migration.

```
php artisan make:migration create_awesome_products_table
```

2. Filling up the migration.

```
public function up()
{
    Schema::create('awesome_products', function (Blueprint $table) {
        $table->id();

        $table->string('name');
        $table->text('description');
        $table->double('price');
        $table->integer('quantity')->nullable();
        $table->dateTime('best_before')->nullable();
        $table->date('production_date')->nullable();
        $table->time('production_time')->nullable();
        $table->boolean('is_active');
        $table->foreignId('category_id')->constrained()->cascadeOnDelete();

        $table->timestamps();
    });
}
```

3. Generating the CRUD.

```
php artisan generate:crud awesome_products AwesomeProduct
```

### Tips

[](#tips)

- The combination of `foreignId()` and `constrained()` methods is essential to make foreign keys work.
- The `cascadeOnDelete()` method is optional.
- Take note on snake\_case naming pattern.

Options
-------

[](#options)

OptionparamsDescriptiontablestringTable name (snake\_case).resourcestringResource name (PascalCase) which will be used to name all files.--style\[default, none\]Specifies the style. Default = default.--language\[br, en\]Specifies the language. Default = en.Configs
-------

[](#configs)

After you had published the css and config folders, you can navigate to config/crudgenerator.php and edit some configs, they are:

ConfigDefaultDescriptionlanguageenSpecifies the language of texts inside the files. Accepts 'br' for 'Português brasileiro' or 'en' for 'English'.styledefaultSpecifies the style of views. Accepts 'default' for default css file or 'none' for raw html.pagination\_per\_page5Specifies the number of elements should be rendered on each page at index's table. Accepts any positive value.- After you edit any config, please be sure of run the `php artisan config:cache`command to apply your changes.

Output
------

[](#output)

After running the `php artisan generate:crud awesome_products AwesomeProduct` command, you'll be able to find these files in your project:

 App\\Http\\Controllers\\AwesomeProductController.php ```
