Blueprint

class Blueprint (View source)

Properties

protected string $table The table the blueprint describes.
protected array $columns The columns that should be added to the table.
protected array $commands The commands that should be run for the table.
string $engine The storage engine that should be used for the table.

Methods

void __construct(string $table, Closure $callback = null)

Create a new schema blueprint.

void build(Connection $connection, Grammar $grammar)

Execute the blueprint against the database.

array toSql(Connection $connection, Grammar $grammar)

Get the raw SQL statements for the blueprint.

void addImpliedCommands()

Add the commands that are implied by the blueprint.

void addFluentIndexes()

Add the index commands fluently specified on columns.

bool creating()

Determine if the blueprint has a create command.

Fluent create()

Indicate that the table needs to be created.

Fluent drop()

Indicate that the table should be dropped.

Fluent dropIfExists()

Indicate that the table should be dropped if it exists.

Fluent dropColumn(string|array $columns)

Indicate that the given columns should be dropped.

Fluent renameColumn(string $from, string $to)

Indicate that the given columns should be renamed.

Fluent dropPrimary(string|array $index = null)

Indicate that the given primary key should be dropped.

Fluent dropUnique(string|array $index)

Indicate that the given unique key should be dropped.

Fluent dropIndex(string|array $index)

Indicate that the given index should be dropped.

Fluent dropForeign(string $index)

Indicate that the given foreign key should be dropped.

void dropTimestamps()

Indicate that the timestamp columns should be dropped.

void dropSoftDeletes()

Indicate that the soft delete column should be dropped.

Fluent rename(string $to)

Rename the table to a given name.

Fluent primary(string|array $columns, string $name = null)

Specify the primary key(s) for the table.

Fluent unique(string|array $columns, string $name = null)

Specify a unique index for the table.

Fluent index(string|array $columns, string $name = null)

Specify an index for the table.

Fluent foreign(string|array $columns, string $name = null)

Specify a foreign key for the table.

Fluent increments(string $column)

Create a new auto-incrementing integer column on the table.

Fluent bigIncrements(string $column)

Create a new auto-incrementing big integer column on the table.

Fluent char(string $column, int $length = 255)

Create a new char column on the table.

Fluent string(string $column, int $length = 255)

Create a new string column on the table.

Fluent text(string $column)

Create a new text column on the table.

Fluent mediumText(string $column)

Create a new medium text column on the table.

Fluent longText(string $column)

Create a new long text column on the table.

Fluent integer(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new integer column on the table.

Fluent bigInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new big integer column on the table.

Fluent mediumInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new medium integer column on the table.

Fluent tinyInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new tiny integer column on the table.

Fluent smallInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new small integer column on the table.

Fluent unsignedInteger(string $column, bool $autoIncrement = false)

Create a new unsigned integer column on the table.

Fluent unsignedBigInteger(string $column, bool $autoIncrement = false)

Create a new unsigned big integer column on the table.

Fluent float(string $column, int $total = 8, int $places = 2)

Create a new float column on the table.

Fluent double(string $column, int|null $total = null, int|null $places = null)

Create a new double column on the table.

Fluent decimal(string $column, int $total = 8, int $places = 2)

Create a new decimal column on the table.

Fluent boolean(string $column)

Create a new boolean column on the table.

Fluent enum(string $column, array $allowed)

Create a new enum column on the table.

Fluent date(string $column)

Create a new date column on the table.

Fluent dateTime(string $column)

Create a new date-time column on the table.

Fluent time(string $column)

Create a new time column on the table.

Fluent timestamp(string $column)

Create a new timestamp column on the table.

void nullableTimestamps()

Add nullable creation and update timestamps to the table.

void timestamps()

Add creation and update timestamps to the table.

Fluent softDeletes()

Add a "deleted at" timestamp for the table.

Fluent binary(string $column)

Create a new binary column on the table.

void morphs(string $name, string|null $indexName = null)

Add the proper columns for a polymorphic table.

Fluent rememberToken()

Adds the remember_token column to the table.

Fluent dropIndexCommand(string $command, string $type, string|array $index)

Create a new drop index command on the blueprint.

Fluent indexCommand(string $type, string|array $columns, string $index)

Add a new index command to the blueprint.

string createIndexName(string $type, array $columns)

Create a default index name for the table.

Fluent addColumn(string $type, string $name, array $parameters = array())

Add a new column to the blueprint.

$this removeColumn(string $name)

Remove a column from the schema blueprint.

Fluent addCommand(string $name, array $parameters = array())

Add a new command to the blueprint.

Fluent createCommand(string $name, array $parameters = array())

Create a new Fluent command.

string getTable()

Get the table the blueprint describes.

array getColumns()

Get the columns that should be added.

array getCommands()

Get the commands on the blueprint.

Details

void __construct(string $table, Closure $callback = null)

Create a new schema blueprint.

Parameters

string $table
Closure $callback

Return Value

void

void build(Connection $connection, Grammar $grammar)

Execute the blueprint against the database.

Parameters

Connection $connection
Grammar $grammar

Return Value

void

array toSql(Connection $connection, Grammar $grammar)

Get the raw SQL statements for the blueprint.

Parameters

Connection $connection
Grammar $grammar

Return Value

array

protected void addImpliedCommands()

Add the commands that are implied by the blueprint.

Return Value

void

protected void addFluentIndexes()

Add the index commands fluently specified on columns.

Return Value

void

protected bool creating()

Determine if the blueprint has a create command.

Return Value

bool

Fluent create()

Indicate that the table needs to be created.

Return Value

Fluent

Fluent drop()

Indicate that the table should be dropped.

Return Value

Fluent

Fluent dropIfExists()

Indicate that the table should be dropped if it exists.

Return Value

Fluent

Fluent dropColumn(string|array $columns)

Indicate that the given columns should be dropped.

Parameters

string|array $columns

Return Value

Fluent

Fluent renameColumn(string $from, string $to)

Indicate that the given columns should be renamed.

Parameters

string $from
string $to

Return Value

Fluent

Fluent dropPrimary(string|array $index = null)

Indicate that the given primary key should be dropped.

Parameters

string|array $index

Return Value

Fluent

Fluent dropUnique(string|array $index)

Indicate that the given unique key should be dropped.

Parameters

string|array $index

Return Value

Fluent

Fluent dropIndex(string|array $index)

Indicate that the given index should be dropped.

Parameters

string|array $index

Return Value

Fluent

Fluent dropForeign(string $index)

Indicate that the given foreign key should be dropped.

Parameters

string $index

Return Value

Fluent

void dropTimestamps()

Indicate that the timestamp columns should be dropped.

Return Value

void

void dropSoftDeletes()

Indicate that the soft delete column should be dropped.

Return Value

void

Fluent rename(string $to)

Rename the table to a given name.

Parameters

string $to

Return Value

Fluent

Fluent primary(string|array $columns, string $name = null)

Specify the primary key(s) for the table.

Parameters

string|array $columns
string $name

Return Value

Fluent

Fluent unique(string|array $columns, string $name = null)

Specify a unique index for the table.

Parameters

string|array $columns
string $name

Return Value

Fluent

Fluent index(string|array $columns, string $name = null)

Specify an index for the table.

Parameters

string|array $columns
string $name

Return Value

Fluent

Fluent foreign(string|array $columns, string $name = null)

Specify a foreign key for the table.

Parameters

string|array $columns
string $name

Return Value

Fluent

Fluent increments(string $column)

Create a new auto-incrementing integer column on the table.

Parameters

string $column

Return Value

Fluent

Fluent bigIncrements(string $column)

Create a new auto-incrementing big integer column on the table.

Parameters

string $column

Return Value

Fluent

Fluent char(string $column, int $length = 255)

Create a new char column on the table.

Parameters

string $column
int $length

Return Value

Fluent

Fluent string(string $column, int $length = 255)

Create a new string column on the table.

Parameters

string $column
int $length

Return Value

Fluent

Fluent text(string $column)

Create a new text column on the table.

Parameters

string $column

Return Value

Fluent

Fluent mediumText(string $column)

Create a new medium text column on the table.

Parameters

string $column

Return Value

Fluent

Fluent longText(string $column)

Create a new long text column on the table.

Parameters

string $column

Return Value

Fluent

Fluent integer(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new integer column on the table.

Parameters

string $column
bool $autoIncrement
bool $unsigned

Return Value

Fluent

Fluent bigInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new big integer column on the table.

Parameters

string $column
bool $autoIncrement
bool $unsigned

Return Value

Fluent

Fluent mediumInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new medium integer column on the table.

Parameters

string $column
bool $autoIncrement
bool $unsigned

Return Value

Fluent

Fluent tinyInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new tiny integer column on the table.

Parameters

string $column
bool $autoIncrement
bool $unsigned

Return Value

Fluent

Fluent smallInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)

Create a new small integer column on the table.

Parameters

string $column
bool $autoIncrement
bool $unsigned

Return Value

Fluent

Fluent unsignedInteger(string $column, bool $autoIncrement = false)

Create a new unsigned integer column on the table.

Parameters

string $column
bool $autoIncrement

Return Value

Fluent

Fluent unsignedBigInteger(string $column, bool $autoIncrement = false)

Create a new unsigned big integer column on the table.

Parameters

string $column
bool $autoIncrement

Return Value

Fluent

Fluent float(string $column, int $total = 8, int $places = 2)

Create a new float column on the table.

Parameters

string $column
int $total
int $places

Return Value

Fluent

Fluent double(string $column, int|null $total = null, int|null $places = null)

Create a new double column on the table.

Parameters

string $column
int|null $total
int|null $places

Return Value

Fluent

Fluent decimal(string $column, int $total = 8, int $places = 2)

Create a new decimal column on the table.

Parameters

string $column
int $total
int $places

Return Value

Fluent

Fluent boolean(string $column)

Create a new boolean column on the table.

Parameters

string $column

Return Value

Fluent

Fluent enum(string $column, array $allowed)

Create a new enum column on the table.

Parameters

string $column
array $allowed

Return Value

Fluent

Fluent date(string $column)

Create a new date column on the table.

Parameters

string $column

Return Value

Fluent

Fluent dateTime(string $column)

Create a new date-time column on the table.

Parameters

string $column

Return Value

Fluent

Fluent time(string $column)

Create a new time column on the table.

Parameters

string $column

Return Value

Fluent

Fluent timestamp(string $column)

Create a new timestamp column on the table.

Parameters

string $column

Return Value

Fluent

void nullableTimestamps()

Add nullable creation and update timestamps to the table.

Return Value

void

void timestamps()

Add creation and update timestamps to the table.

Return Value

void

Fluent softDeletes()

Add a "deleted at" timestamp for the table.

Return Value

Fluent

Fluent binary(string $column)

Create a new binary column on the table.

Parameters

string $column

Return Value

Fluent

void morphs(string $name, string|null $indexName = null)

Add the proper columns for a polymorphic table.

Parameters

string $name
string|null $indexName

Return Value

void

Fluent rememberToken()

Adds the remember_token column to the table.

Return Value

Fluent

protected Fluent dropIndexCommand(string $command, string $type, string|array $index)

Create a new drop index command on the blueprint.

Parameters

string $command
string $type
string|array $index

Return Value

Fluent

protected Fluent indexCommand(string $type, string|array $columns, string $index)

Add a new index command to the blueprint.

Parameters

string $type
string|array $columns
string $index

Return Value

Fluent

protected string createIndexName(string $type, array $columns)

Create a default index name for the table.

Parameters

string $type
array $columns

Return Value

string

protected Fluent addColumn(string $type, string $name, array $parameters = array())

Add a new column to the blueprint.

Parameters

string $type
string $name
array $parameters

Return Value

Fluent

$this removeColumn(string $name)

Remove a column from the schema blueprint.

Parameters

string $name

Return Value

$this

protected Fluent addCommand(string $name, array $parameters = array())

Add a new command to the blueprint.

Parameters

string $name
array $parameters

Return Value

Fluent

protected Fluent createCommand(string $name, array $parameters = array())

Create a new Fluent command.

Parameters

string $name
array $parameters

Return Value

Fluent

string getTable()

Get the table the blueprint describes.

Return Value

string

array getColumns()

Get the columns that should be added.

Return Value

array

array getCommands()

Get the commands on the blueprint.

Return Value

array

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/4.2/Illuminate/Database/Schema/Blueprint.html