class Illuminate / Database / Schema / Blueprint
You are viewing an older version of the documentation. For the latest, please visit master documentation.

Blueprint

Uses

Properties

protected

$table string

The table the blueprint describes.

Default: null
protected

$prefix string

The prefix of the table.

Default: null
protected

$columns Illuminate\...\ColumnDefinition[]

The columns that should be added to the table.

Default: []
protected

$commands Illuminate\...\Fluent[]

The commands that should be run for the table.

Default: []
public

$engine string

The storage engine that should be used for the table.

Default: null
public

$charset string

The default character set that should be used for the table.

Default: null
public

$collation string

The collation that should be used for the table.

Default: null
public

$temporary bool

Whether to make the table temporary.

Default: false
public

$after string

The column to add new columns after.

Default: null

Methods

public

__construct ( $table , Closure $callback , $prefix ) : void

Create a new schema blueprint.

Parameters

  • $table string
  • $callback Closure |null
  • $prefix string
public

build ( Connection $connection , Grammar $grammar ) : void

Execute the blueprint against the database.

Parameters

public

toSql ( Connection $connection , Grammar $grammar ) : array

Get the raw SQL statements for the blueprint.

Parameters

protected

ensureCommandsAreValid ( Connection $connection ) : void

Ensure the commands on the blueprint are valid for the connection type.

Parameters

protected

commandsNamed ( array $names ) : Collection

Get all of the commands matching the given names.

Parameters

  • $names array
protected

addImpliedCommands ( Grammar $grammar ) : void

Add the commands that are implied by the blueprint's state.

Parameters

protected

addFluentIndexes ( ) : void

Add the index commands fluently specified on columns.

public

addFluentCommands ( Grammar $grammar ) : void

Add the fluent commands specified on any columns.

Parameters

public

creating ( ) : bool

Determine if the blueprint has a create command.

public

create ( ) : Fluent

Indicate that the table needs to be created.

public

temporary ( ) : void

Indicate that the table needs to be temporary.

public

drop ( ) : Fluent

Indicate that the table should be dropped.

public

dropIfExists ( ) : Fluent

Indicate that the table should be dropped if it exists.

public

dropColumn ( $columns ) : Fluent

Indicate that the given columns should be dropped.

Parameters

  • $columns array|mixed
public

renameColumn ( $from , $to ) : Fluent

Indicate that the given columns should be renamed.

Parameters

  • $from string
  • $to string
public

dropPrimary ( $index ) : Fluent

Indicate that the given primary key should be dropped.

Parameters

  • $index string|array|null
public

dropUnique ( $index ) : Fluent

Indicate that the given unique key should be dropped.

Parameters

  • $index string|array
public

dropIndex ( $index ) : Fluent

Indicate that the given index should be dropped.

Parameters

  • $index string|array
public

dropFullText ( $index ) : Fluent

Indicate that the given fulltext index should be dropped.

Parameters

  • $index string|array
public

dropSpatialIndex ( $index ) : Fluent

Indicate that the given spatial index should be dropped.

Parameters

  • $index string|array
public

dropForeign ( $index ) : Fluent

Indicate that the given foreign key should be dropped.

Parameters

  • $index string|array
public

dropConstrainedForeignId ( $column ) : Fluent

Indicate that the given column and foreign key should be dropped.

Parameters

  • $column string
public

renameIndex ( $from , $to ) : Fluent

Indicate that the given indexes should be renamed.

Parameters

  • $from string
  • $to string
public

dropTimestamps ( ) : void

Indicate that the timestamp columns should be dropped.

public

dropTimestampsTz ( ) : void

Indicate that the timestamp columns should be dropped.

public

dropSoftDeletes ( $column ) : void

Indicate that the soft delete column should be dropped.

Parameters

  • $column string
public

dropSoftDeletesTz ( $column ) : void

Indicate that the soft delete column should be dropped.

Parameters

  • $column string
public

dropRememberToken ( ) : void

Indicate that the remember token column should be dropped.

public

dropMorphs ( $name , $indexName ) : void

Indicate that the polymorphic columns should be dropped.

Parameters

  • $name string
  • $indexName string|null
public

rename ( $to ) : Fluent

Rename the table to a given name.

Parameters

  • $to string
public

primary ( $columns , $name , $algorithm ) : Fluent

Specify the primary key(s) for the table.

Parameters

  • $columns string|array
  • $name string|null
  • $algorithm string|null
public

unique ( $columns , $name , $algorithm ) : Fluent

Specify a unique index for the table.

Parameters

  • $columns string|array
  • $name string|null
  • $algorithm string|null
public

index ( $columns , $name , $algorithm ) : Fluent

Specify an index for the table.

Parameters

  • $columns string|array
  • $name string|null
  • $algorithm string|null
public

fullText ( $columns , $name , $algorithm ) : Fluent

Specify an fulltext for the table.

Parameters

  • $columns string|array
  • $name string|null
  • $algorithm string|null
public

spatialIndex ( $columns , $name ) : Fluent

Specify a spatial index for the table.

Parameters

  • $columns string|array
  • $name string|null
public

rawIndex ( $expression , $name ) : Fluent

Specify a raw index for the table.

Parameters

  • $expression string
  • $name string
public

foreign ( $columns , $name ) : ForeignKeyDefinition

Specify a foreign key for the table.

Parameters

  • $columns string|array
  • $name string|null
public

id ( $column ) : ColumnDefinition

Create a new auto-incrementing big integer (8-byte) column on the table.

Parameters

  • $column string
public

increments ( $column ) : ColumnDefinition

Create a new auto-incrementing integer (4-byte) column on the table.

Parameters

  • $column string
public

integerIncrements ( $column ) : ColumnDefinition

Create a new auto-incrementing integer (4-byte) column on the table.

Parameters

  • $column string
public

tinyIncrements ( $column ) : ColumnDefinition

Create a new auto-incrementing tiny integer (1-byte) column on the table.

Parameters

  • $column string
public

smallIncrements ( $column ) : ColumnDefinition

Create a new auto-incrementing small integer (2-byte) column on the table.

Parameters

  • $column string
public

mediumIncrements ( $column ) : ColumnDefinition

Create a new auto-incrementing medium integer (3-byte) column on the table.

Parameters

  • $column string
public

bigIncrements ( $column ) : ColumnDefinition

Create a new auto-incrementing big integer (8-byte) column on the table.

Parameters

  • $column string
public

char ( $column , $length ) : ColumnDefinition

Create a new char column on the table.

Parameters

  • $column string
  • $length int|null
public

string ( $column , $length ) : ColumnDefinition

Create a new string column on the table.

Parameters

  • $column string
  • $length int|null
public

tinyText ( $column ) : ColumnDefinition

Create a new tiny text column on the table.

Parameters

  • $column string
public

text ( $column ) : ColumnDefinition

Create a new text column on the table.

Parameters

  • $column string
public

mediumText ( $column ) : ColumnDefinition

Create a new medium text column on the table.

Parameters

  • $column string
public

longText ( $column ) : ColumnDefinition

Create a new long text column on the table.

Parameters

  • $column string
public

integer ( $column , $autoIncrement , $unsigned ) : ColumnDefinition

Create a new integer (4-byte) column on the table.

Parameters

  • $column string
  • $autoIncrement bool
  • $unsigned bool
public

tinyInteger ( $column , $autoIncrement , $unsigned ) : ColumnDefinition

Create a new tiny integer (1-byte) column on the table.

Parameters

  • $column string
  • $autoIncrement bool
  • $unsigned bool
public

smallInteger ( $column , $autoIncrement , $unsigned ) : ColumnDefinition

Create a new small integer (2-byte) column on the table.

Parameters

  • $column string
  • $autoIncrement bool
  • $unsigned bool
public

mediumInteger ( $column , $autoIncrement , $unsigned ) : ColumnDefinition

Create a new medium integer (3-byte) column on the table.

Parameters

  • $column string
  • $autoIncrement bool
  • $unsigned bool
public

bigInteger ( $column , $autoIncrement , $unsigned ) : ColumnDefinition

Create a new big integer (8-byte) column on the table.

Parameters

  • $column string
  • $autoIncrement bool
  • $unsigned bool
public

unsignedInteger ( $column , $autoIncrement ) : ColumnDefinition

Create a new unsigned integer (4-byte) column on the table.

Parameters

  • $column string
  • $autoIncrement bool
public

unsignedTinyInteger ( $column , $autoIncrement ) : ColumnDefinition

Create a new unsigned tiny integer (1-byte) column on the table.

Parameters

  • $column string
  • $autoIncrement bool
public

unsignedSmallInteger ( $column , $autoIncrement ) : ColumnDefinition

Create a new unsigned small integer (2-byte) column on the table.

Parameters

  • $column string
  • $autoIncrement bool
public

unsignedMediumInteger ( $column , $autoIncrement ) : ColumnDefinition

Create a new unsigned medium integer (3-byte) column on the table.

Parameters

  • $column string
  • $autoIncrement bool
public

unsignedBigInteger ( $column , $autoIncrement ) : ColumnDefinition

Create a new unsigned big integer (8-byte) column on the table.

Parameters

  • $column string
  • $autoIncrement bool
public

foreignId ( $column ) : ForeignIdColumnDefinition

Create a new unsigned big integer (8-byte) column on the table.

Parameters

  • $column string
public

foreignIdFor ( $model , $column ) : ForeignIdColumnDefinition

Create a foreign ID column for the given model.

Parameters

  • $model Model |string
  • $column string|null
public

float ( $column , $total , $places , $unsigned ) : ColumnDefinition

Create a new float column on the table.

Parameters

  • $column string
  • $total int
  • $places int
  • $unsigned bool
public

double ( $column , $total , $places , $unsigned ) : ColumnDefinition

Create a new double column on the table.

Parameters

  • $column string
  • $total int|null
  • $places int|null
  • $unsigned bool
public

decimal ( $column , $total , $places , $unsigned ) : ColumnDefinition

Create a new decimal column on the table.

Parameters

  • $column string
  • $total int
  • $places int
  • $unsigned bool
public

unsignedFloat ( $column , $total , $places ) : ColumnDefinition

Create a new unsigned float column on the table.

Parameters

  • $column string
  • $total int
  • $places int
public

unsignedDouble ( $column , $total , $places ) : ColumnDefinition

Create a new unsigned double column on the table.

Parameters

  • $column string
  • $total int
  • $places int
public

unsignedDecimal ( $column , $total , $places ) : ColumnDefinition

Create a new unsigned decimal column on the table.

Parameters

  • $column string
  • $total int
  • $places int
public

boolean ( $column ) : ColumnDefinition

Create a new boolean column on the table.

Parameters

  • $column string
public

enum ( $column , array $allowed ) : ColumnDefinition

Create a new enum column on the table.

Parameters

  • $column string
  • $allowed array
public

set ( $column , array $allowed ) : ColumnDefinition

Create a new set column on the table.

Parameters

  • $column string
  • $allowed array
public

json ( $column ) : ColumnDefinition

Create a new json column on the table.

Parameters

  • $column string
public

jsonb ( $column ) : ColumnDefinition

Create a new jsonb column on the table.

Parameters

  • $column string
public

date ( $column ) : ColumnDefinition

Create a new date column on the table.

Parameters

  • $column string
public

dateTime ( $column , $precision ) : ColumnDefinition

Create a new date-time column on the table.

Parameters

  • $column string
  • $precision int
public

dateTimeTz ( $column , $precision ) : ColumnDefinition

Create a new date-time column (with time zone) on the table.

Parameters

  • $column string
  • $precision int
public

time ( $column , $precision ) : ColumnDefinition

Create a new time column on the table.

Parameters

  • $column string
  • $precision int
public

timeTz ( $column , $precision ) : ColumnDefinition

Create a new time column (with time zone) on the table.

Parameters

  • $column string
  • $precision int
public

timestamp ( $column , $precision ) : ColumnDefinition

Create a new timestamp column on the table.

Parameters

  • $column string
  • $precision int
public

timestampTz ( $column , $precision ) : ColumnDefinition

Create a new timestamp (with time zone) column on the table.

Parameters

  • $column string
  • $precision int
public

timestamps ( $precision ) : void

Add nullable creation and update timestamps to the table.

Parameters

  • $precision int
public

nullableTimestamps ( $precision ) : void

Add nullable creation and update timestamps to the table.

Parameters

  • $precision int
public

timestampsTz ( $precision ) : void

Add creation and update timestampTz columns to the table.

Parameters

  • $precision int
public

softDeletes ( $column , $precision ) : ColumnDefinition

Add a "deleted at" timestamp for the table.

Parameters

  • $column string
  • $precision int
public

softDeletesTz ( $column , $precision ) : ColumnDefinition

Add a "deleted at" timestampTz for the table.

Parameters

  • $column string
  • $precision int
public

year ( $column ) : ColumnDefinition

Create a new year column on the table.

Parameters

  • $column string
public

binary ( $column ) : ColumnDefinition

Create a new binary column on the table.

Parameters

  • $column string
public

uuid ( $column ) : ColumnDefinition

Create a new uuid column on the table.

Parameters

  • $column string
public

foreignUuid ( $column ) : ForeignIdColumnDefinition

Create a new UUID column on the table with a foreign key constraint.

Parameters

  • $column string
public

ipAddress ( $column ) : ColumnDefinition

Create a new IP address column on the table.

Parameters

  • $column string
public

macAddress ( $column ) : ColumnDefinition

Create a new MAC address column on the table.

Parameters

  • $column string
public

geometry ( $column ) : ColumnDefinition

Create a new geometry column on the table.

Parameters

  • $column string
public

point ( $column , $srid ) : ColumnDefinition

Create a new point column on the table.

Parameters

  • $column string
  • $srid int|null
public

lineString ( $column ) : ColumnDefinition

Create a new linestring column on the table.

Parameters

  • $column string
public

polygon ( $column ) : ColumnDefinition

Create a new polygon column on the table.

Parameters

  • $column string
public

geometryCollection ( $column ) : ColumnDefinition

Create a new geometrycollection column on the table.

Parameters

  • $column string
public

multiPoint ( $column ) : ColumnDefinition

Create a new multipoint column on the table.

Parameters

  • $column string
public

multiLineString ( $column ) : ColumnDefinition

Create a new multilinestring column on the table.

Parameters

  • $column string
public

multiPolygon ( $column ) : ColumnDefinition

Create a new multipolygon column on the table.

Parameters

  • $column string
public

multiPolygonZ ( $column ) : ColumnDefinition

Create a new multipolygon column on the table.

Parameters

  • $column string
public

computed ( $column , $expression ) : ColumnDefinition

Create a new generated, computed column on the table.

Parameters

  • $column string
  • $expression string
public

morphs ( $name , $indexName ) : void

Add the proper columns for a polymorphic table.

Parameters

  • $name string
  • $indexName string|null
public

nullableMorphs ( $name , $indexName ) : void

Add nullable columns for a polymorphic table.

Parameters

  • $name string
  • $indexName string|null
public

numericMorphs ( $name , $indexName ) : void

Add the proper columns for a polymorphic table using numeric IDs (incremental).

Parameters

  • $name string
  • $indexName string|null
public

nullableNumericMorphs ( $name , $indexName ) : void

Add nullable columns for a polymorphic table using numeric IDs (incremental).

Parameters

  • $name string
  • $indexName string|null
public

uuidMorphs ( $name , $indexName ) : void

Add the proper columns for a polymorphic table using UUIDs.

Parameters

  • $name string
  • $indexName string|null
public

nullableUuidMorphs ( $name , $indexName ) : void

Add nullable columns for a polymorphic table using UUIDs.

Parameters

  • $name string
  • $indexName string|null
public

rememberToken ( ) : ColumnDefinition

Adds the remember_token column to the table.

protected

indexCommand ( $type , $columns , $index , $algorithm ) : Fluent

Add a new index command to the blueprint.

Parameters

  • $type string
  • $columns string|array
  • $index string
  • $algorithm string|null
protected

dropIndexCommand ( $command , $type , $index ) : Fluent

Create a new drop index command on the blueprint.

Parameters

  • $command string
  • $type string
  • $index string|array
protected

createIndexName ( $type , array $columns ) : string

Create a default index name for the table.

Parameters

  • $type string
  • $columns array
public

addColumn ( $type , $name , array $parameters ) : ColumnDefinition

Add a new column to the blueprint.

Parameters

  • $type string
  • $name string
  • $parameters array
protected

addColumnDefinition ( $definition ) : ColumnDefinition

Add a new column definition to the blueprint.

Parameters

public

after ( $column , Closure $callback ) : void

Add the columns from the callback after the given column.

Parameters

public

removeColumn ( $name ) : $this

Remove a column from the schema blueprint.

Parameters

  • $name string
protected

addCommand ( $name , array $parameters ) : Fluent

Add a new command to the blueprint.

Parameters

  • $name string
  • $parameters array
protected

createCommand ( $name , array $parameters ) : Fluent

Create a new Fluent command.

Parameters

  • $name string
  • $parameters array
public

getTable ( ) : string

Get the table the blueprint describes.

public

getColumns ( ) : Illuminate\...\ColumnDefinition[]

Get the columns on the blueprint.

public

getCommands ( ) : Illuminate\...\Fluent[]

Get the commands on the blueprint.

public

getAddedColumns ( ) : Illuminate\...\ColumnDefinition[]

Get the columns on the blueprint that should be added.

public

getChangedColumns ( ) : Illuminate\...\ColumnDefinition[]

Get the columns on the blueprint that should be changed.

public

hasAutoIncrementColumn ( ) : bool

Determine if the blueprint has auto-increment columns.

public

autoIncrementingStartingValues ( ) : array

Get the auto-increment column starting values.