Skip to content
On this page

Columns

Define a column with a name, and the value as the method to call from Blueprint class instance. Additional arguments for the method can be defined after the colon, and separated by comma.

yaml
models:
  Post:
    claps: integer:true,true nullable
1
2
3
php
Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->integer('claps', true, true)->nullable();
    $table->timestamps();
});
1
2
3
4
5

While the above syntax will work for Quick Models, you can have total control on the model itself using Custom Models. For the latter, put your columns and relations inside the columns key.

yaml
models:
  Post:
    columns:
      claps: integer:true,true nullable
1
2
3
4
php
Schema::create('posts', function (Blueprint $table) {
    $table->integer('claps', true, true)->nullable();
});
1
2
3

I'll use my own method

If you have a package adding custom columns types, like $table->custom('foo') or $table->foo(), no problem, you can typefoo: custom or foo: ~, respectively.

Since there is no method checking, you should be careful of typos, as cool_at: timetsamp will become $table->timetsamp('cool_at').

Columns with no values

Column keys with null values, for both Quick Models and Custom Models, will transform into method names with no arguments. This is used for timestamps, soft-deletes and other short-hands from the Blueprint.

yaml
models:
  Posts:
    columns:
      id: ~
      uuid: ~
      softDeletes: ~
      timestampsTz: ~
      rememberToken: ~
      myCustomMethod: ~
1
2
3
4
5
6
7
8
9
php
Schema::create('model_name', function (Blueprint $table) {
    $table->id();
    $table->uuid();
    $table->softDeletes();
    $table->timestampsTz();
    $table->rememberToken();
    $table->myCustomMethod();
});
1
2
3
4
5
6
7
8

Prefer the wavy thing

To issue a null value, use ~. Some YAML parsers run in circles when a value is empty.