Blueprint
class Blueprint
Handles schema definitions before executing them.
Methods
Constructor for Blueprint class.
Specifies the position of the last defined column to appear immediately after another column in the table (MySQL only).
Define a big integer column.
Create the table.
Drops a column or group of columns. If a column has a restraint then warnings are presented to the user.
Drops a foreign key constraint from the table (MySQL only).
Drops a table if it exists.
Drops indexed value from the table.
Drops primary key field from the table.
Drops column with unique constraint from the table.
Define a foreign key (MySQL only).
Add an ID column (primary key).
Define an index.
Define a medium integer column.
Renames a particular column
Renames a foreign key.
Renames an indexed column by preserving and reapplying the index.
Renames the table's primary key.
Renames a column with a unique constraint by preserving and reapplying the index.
Define a small integer column.
Define a soft delete column.
Define timestamps (created_at and updated_at).
Define a tiny integer column.
Define an unsigned integer column (MySQL only).
Define an unsigned big integer column (MySQL only).
Update an existing table.
Define a UUID column (MySQL only).
Details
at line 30
__construct(string $table)
Constructor for Blueprint class.
at line 50
Blueprint
after(string $column)
Specifies the position of the last defined column to appear immediately after another column in the table (MySQL only).
This method is only meaningful during ALTER TABLE operations
(i.e., when calling $table->update()). The generated SQL will
include an AFTER column_name clause to control column order.
Example: $table->string('nickname')->after('last_name'); // Produces: ALTER TABLE users ADD COLUMN nickname VARCHAR(255) AFTER last_name;
at line 63
Blueprint
bigInteger(string $name)
Define a big integer column.
at line 75
Blueprint
boolean(string $name)
Define a boolean column.
at line 84
void
create()
Create the table.
at line 159
Blueprint
date(string $name)
Define a date column.
at line 171
Blueprint
dateTime(string $name)
Define a datetime column.
at line 185
Blueprint
decimal(string $name, int $precision = 8, int $scale = 2)
Define a decimal column.
at line 205
Blueprint
default(string|int|float|bool $value)
Adds a DEFAULT value to the last defined column.
This method appends a default value to the most recently added column in the schema definition. It supports string, integer, float, and boolean values. If no columns have been added yet, it throws an exception. In SQLite, default values for certain column types like TEXT and BLOB are skipped.
at line 236
void
dropColumns(array|string $columns)
Drops a column or group of columns. If a column has a restraint then warnings are presented to the user.
at line 292
void
dropForeign(string $column, bool $preserveColumn = true)
Drops a foreign key constraint from the table (MySQL only).
at line 327
void
dropIfExists(string $table)
Drops a table if it exists.
at line 342
void
dropIndex(string $column, bool $preserveColumn = true)
Drops indexed value from the table.
at line 375
void
dropPrimaryKey(string $column, bool $preserveColumn = true)
Drops primary key field from the table.
at line 407
void
dropUnique(string $column, bool $preserveColumn = false)
Drops column with unique constraint from the table.
at line 478
Blueprint
double(string $name, int $precision = 16, int $scale = 4)
Define a double column.
at line 491
Blueprint
enum(string $name, array $values)
Define an enum column (MySQL only).
at line 510
Blueprint
float(string $name, int $precision = 8, int $scale = 2)
Define a float column.
at line 525
void
foreign(string $column, string $referencedColumn, string $onTable, string $onDelete = 'RESTRICT', string $onUpdate = 'RESTRICT')
Define a foreign key (MySQL only).
at line 574
id()
Add an ID column (primary key).
at line 584
void
index(string $column)
Define an index.
at line 745
Blueprint
integer(string $name)
Define an integer column.
at line 758
Blueprint
mediumInteger(string $name)
Define a medium integer column.
at line 769
Blueprint
nullable()
Modifies last column added to the schema and make it nullable.
at line 784
void
renameColumn(string $from, string $to)
Renames a particular column
at line 809
void
renameForeign(string $from, string $to)
Renames a foreign key.
at line 851
void
renameIndex(string $from, string $to)
Renames an indexed column by preserving and reapplying the index.
at line 886
void
renamePrimaryKey(string $from, string $to)
Renames the table's primary key.
at line 921
void
renameUnique(string $from, string $to)
Renames a column with a unique constraint by preserving and reapplying the index.
at line 987
Blueprint
smallInteger(string $name)
Define a small integer column.
at line 998
Blueprint
softDeletes()
Define a soft delete column.
at line 1010
Blueprint
string(string $name, int $length = 255)
Define a string column.
at line 1023
Blueprint
text(string $name)
Define a text column.
at line 1035
Blueprint
time(string $name)
Define a time column.
at line 1047
Blueprint
timestamp(string $name)
Define a timestamp column.
at line 1056
void
timestamps()
Define timestamps (created_at and updated_at).
at line 1067
Blueprint
tinyInteger(string $name)
Define a tiny integer column.
at line 1080
Blueprint
unique()
Adds a unique index to the last defined column.
at line 1096
Blueprint
unsignedInteger(string $name)
Define an unsigned integer column (MySQL only).
at line 1112
Blueprint
unsignedBigInteger(string $name)
Define an unsigned big integer column (MySQL only).
at line 1126
void
update()
Update an existing table.
at line 1158
uuid(string $name)
Define a UUID column (MySQL only).