PHPackages                             ericli1018/laracasts-generators - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ericli1018/laracasts-generators

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ericli1018/laracasts-generators
===============================

0.0.1(6mo ago)01MITPHP

Since Oct 28Pushed 6mo agoCompare

[ Source](https://github.com/ericli1018/laracasts-generators)[ Packagist](https://packagist.org/packages/ericli1018/laracasts-generators)[ RSS](/packages/ericli1018-laracasts-generators/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Extended Migration Generators for Laravel 6, 7, 8 , 9 , 10 , 11 and 12
======================================================================

[](#extended-migration-generators-for-laravel-6-7-8--9--10--11-and-12)

Easily define the migration schema right in your `make:migration` command. The new commands this package provides are:

- `make:migration:schema`
- `make:migration:pivot`

Which allows you to do `php artisan make:migration:schema create_dogs_table --schema="name:string:nullable, description:text, age:integer, email:string:unique"` and get a full migration that you can run using `php artisan migrate`. For simple cases like this one, no need to tinker inside the migration file itself. And if you do need to change anything, it's easier because the bulk of the code has already been generated.

Created in 2015 by [Jeffrey Way](https://github.com/jeffreyway) as a natural progression of his [JeffreyWay/Laravel-4-Generators](https://github.com/JeffreyWay/Laravel-4-Generators) package, to provide the same features for Laravel 5. Since 2017 it's been maintained by the [Backpack for Laravel](https://github.com/laravel-backpack/crud) team, with features and fixes added by community members like you. So feel free to pitch in.

[![https://user-images.githubusercontent.com/1032474/92732702-cd8b3700-f344-11ea-8e3b-ae86501d66fe.gif](https://user-images.githubusercontent.com/1032474/92732702-cd8b3700-f344-11ea-8e3b-ae86501d66fe.gif)](https://user-images.githubusercontent.com/1032474/92732702-cd8b3700-f344-11ea-8e3b-ae86501d66fe.gif)

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Examples](#examples)
    - [Migrations With Schema](#migrations-with-schema)
        - [Foreign Constraints](#foreign-constraints)
    - [Pivot Tables](#pivot-tables)

Installation
------------

[](#installation)

You can install v2 of this project using composer, the service provider will be automatically loaded by Laravel itself:

```
composer require --dev ericli1018/laracasts-generators

```

You're all set. Run `php artisan` from the console, and you'll see the new commands in the `make:*` namespace section.

Examples
--------

[](#examples)

- [Migrations With Schema](#migrations-with-schema)
- [Pivot Tables](#pivot-tables)

### Migrations With Schema

[](#migrations-with-schema)

```
php artisan make:migration:schema create_users_table --schema="username:string, email:string:unique"

```

Notice the format that we use, when declaring any applicable schema: a comma-separated list...

```
COLUMN_NAME:COLUMN_TYPE

```

So any of these will do:

```
username:string
body:text
age:integer
published_at:date
excerpt:text:nullable
email:string:unique:default('foo@example.com')

```

Using the schema from earlier...

```
--schema="username:string, email:string:unique"

```

...this will give you:

```
