Skip to content

Attributes

Attributes are used to define the properties of a column. These can be chained to the column definition.

unsigned()

Defines the column as an unsigned integer, allowing only positive values.

Example:

php
$schema = new Schema( 'my_table', function ( Schema $table ) {
	$table->column( 'id' )->int()->unsigned();
});

auto_increment()

Defines the column as an auto-incrementing integer, automatically generating a unique value for each new record.

Example:

php
$schema = new Schema( 'my_table', function ( Schema $table ) {
	$table->column( 'id' )->int()->auto_increment();
});

default()

Defines the default value for the column.

Example:

php
$schema = new Schema( 'my_table', function ( Schema $table ) {
	$table->column( 'name' )->varchar( 255 )->default( 'John Doe' );
});

nullable()

Defines the column as nullable, allowing it to be empty.

Example:

php
$schema = new Schema( 'my_table', function ( Schema $table ) {
	$table->column( 'name' )->varchar( 255 )->nullable();
});