Blueprint
class Blueprint (View source)
Traits
Properties
static protected array | $macros | The registered string macros. | from Macroable |
protected string | $table | The table the blueprint describes. | |
protected Fluent[] | $columns | The columns that should be added to the table. | |
protected Fluent[] | $commands | The commands that should be run for the table. | |
string | $engine | The storage engine that should be used for the table. | |
$charset | The default character set that should be used for the table. | ||
$collation | The collation that should be used for the table. | ||
bool | $temporary | Whether to make the table temporary. |
Methods
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Ensure the commands on the blueprint are valid for the connection type.
Get all of the commands matching the given names.
Add the index commands fluently specified on columns.
Determine if the blueprint has a create command.
Indicate that the table needs to be temporary.
Indicate that the table should be dropped if it exists.
Indicate that the given columns should be dropped.
Indicate that the given columns should be renamed.
Indicate that the given primary key should be dropped.
Indicate that the given unique key should be dropped.
Indicate that the given spatial index should be dropped.
Indicate that the given foreign key should be dropped.
Indicate that the given indexes should be renamed.
Indicate that the timestamp columns should be dropped.
Indicate that the timestamp columns should be dropped.
Indicate that the soft delete column should be dropped.
Indicate that the soft delete column should be dropped.
Indicate that the remember token column should be dropped.
Indicate that the polymorphic columns should be dropped.
Specify the primary key(s) for the table.
Specify a unique index for the table.
Specify an index for the table.
Specify a spatial index for the table.
Create a new auto-incrementing integer (4-byte) column on the table.
Create a new auto-incrementing tiny integer (1-byte) column on the table.
Create a new auto-incrementing small integer (2-byte) column on the table.
Create a new auto-incrementing medium integer (3-byte) column on the table.
Create a new auto-incrementing big integer (8-byte) column on the table.
Create a new medium text column on the table.
Create a new integer (4-byte) column on the table.
Create a new tiny integer (1-byte) column on the table.
Create a new small integer (2-byte) column on the table.
Create a new medium integer (3-byte) column on the table.
Create a new big integer (8-byte) column on the table.
Create a new unsigned integer (4-byte) column on the table.
Create a new unsigned tiny integer (1-byte) column on the table.
Create a new unsigned small integer (2-byte) column on the table.
Create a new unsigned medium integer (3-byte) column on the table.
Create a new unsigned big integer (8-byte) column on the table.
Create a new float column on the table.
Create a new double column on the table.
Create a new decimal column on the table.
Create a new unsigned decimal column on the table.
Create a new date-time column (with time zone) on the table.
Create a new time column (with time zone) on the table.
Create a new timestamp (with time zone) column on the table.
Add nullable creation and update timestamps to the table.
Add nullable creation and update timestamps to the table.
Add creation and update timestampTz columns to the table.
Add a "deleted at" timestamp for the table.
Add a "deleted at" timestampTz for the table.
Create a new MAC address column on the table.
Create a new linestring column on the table.
Create a new geometrycollection column on the table.
Create a new multipoint column on the table.
Create a new multilinestring column on the table.
Create a new multipolygon column on the table.
Add the proper columns for a polymorphic table.
Add nullable columns for a polymorphic table.
Adds the remember_token
column to the table.
Add a new index command to the blueprint.
Create a new drop index command on the blueprint.
Create a default index name for the table.
Add a new column to the blueprint.
Remove a column from the schema blueprint.
Add a new command to the blueprint.
Create a new Fluent command.
Get the table the blueprint describes.
Get the columns on the blueprint.
Get the commands on the blueprint.
Get the columns on the blueprint that should be added.
Get the columns on the blueprint that should be changed.
Details
static void
macro(string $name, object|callable $macro)
Register a custom macro.
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 85
void
build(Connection $connection, Grammar $grammar)
Execute the blueprint against the database.
at line 99
array
toSql(Connection $connection, Grammar $grammar)
Get the raw SQL statements for the blueprint.
at line 129
protected void
ensureCommandsAreValid(Connection $connection)
Ensure the commands on the blueprint are valid for the connection type.
at line 145
protected Collection
commandsNamed(array $names)
Get all of the commands matching the given names.
at line 158
protected void
addImpliedCommands(Grammar $grammar)
Add the commands that are implied by the blueprint's state.
at line 178
protected void
addFluentIndexes()
Add the index commands fluently specified on columns.
at line 209
void
addFluentCommands(Grammar $grammar)
Add the fluent commands specified on any columns.
at line 233
protected bool
creating()
Determine if the blueprint has a create command.
at line 255
void
temporary()
Indicate that the table needs to be temporary.
at line 286
Fluent
dropColumn(array|mixed $columns)
Indicate that the given columns should be dropped.
at line 300
Fluent
renameColumn(string $from, string $to)
Indicate that the given columns should be renamed.
at line 311
Fluent
dropPrimary(string|array $index = null)
Indicate that the given primary key should be dropped.
at line 322
Fluent
dropUnique(string|array $index)
Indicate that the given unique key should be dropped.
at line 344
Fluent
dropSpatialIndex(string|array $index)
Indicate that the given spatial index should be dropped.
at line 355
Fluent
dropForeign(string|array $index)
Indicate that the given foreign key should be dropped.
at line 367
Fluent
renameIndex(string $from, string $to)
Indicate that the given indexes should be renamed.
at line 377
void
dropTimestamps()
Indicate that the timestamp columns should be dropped.
at line 387
void
dropTimestampsTz()
Indicate that the timestamp columns should be dropped.
at line 397
void
dropSoftDeletes()
Indicate that the soft delete column should be dropped.
at line 407
void
dropSoftDeletesTz()
Indicate that the soft delete column should be dropped.
at line 417
void
dropRememberToken()
Indicate that the remember token column should be dropped.
at line 429
void
dropMorphs(string $name, string|null $indexName = null)
Indicate that the polymorphic columns should be dropped.
at line 455
Fluent
primary(string|array $columns, string $name = null, string|null $algorithm = null)
Specify the primary key(s) for the table.
at line 468
Fluent
unique(string|array $columns, string $name = null, string|null $algorithm = null)
Specify a unique index for the table.
at line 481
Fluent
index(string|array $columns, string $name = null, string|null $algorithm = null)
Specify an index for the table.
at line 493
Fluent
spatialIndex(string|array $columns, string $name = null)
Specify a spatial index for the table.
at line 505
Fluent
foreign(string|array $columns, string $name = null)
Specify a foreign key for the table.
at line 516
Fluent
increments(string $column)
Create a new auto-incrementing integer (4-byte) column on the table.
at line 527
Fluent
tinyIncrements(string $column)
Create a new auto-incrementing tiny integer (1-byte) column on the table.
at line 538
Fluent
smallIncrements(string $column)
Create a new auto-incrementing small integer (2-byte) column on the table.
at line 549
Fluent
mediumIncrements(string $column)
Create a new auto-incrementing medium integer (3-byte) column on the table.
at line 560
Fluent
bigIncrements(string $column)
Create a new auto-incrementing big integer (8-byte) column on the table.
at line 586
Fluent
string(string $column, int $length = null)
Create a new string column on the table.
at line 634
Fluent
integer(string $column, bool $autoIncrement = false, bool $unsigned = false)
Create a new integer (4-byte) column on the table.
at line 647
Fluent
tinyInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)
Create a new tiny integer (1-byte) column on the table.
at line 660
Fluent
smallInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)
Create a new small integer (2-byte) column on the table.
at line 673
Fluent
mediumInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)
Create a new medium integer (3-byte) column on the table.
at line 686
Fluent
bigInteger(string $column, bool $autoIncrement = false, bool $unsigned = false)
Create a new big integer (8-byte) column on the table.
at line 698
Fluent
unsignedInteger(string $column, bool $autoIncrement = false)
Create a new unsigned integer (4-byte) column on the table.
at line 710
Fluent
unsignedTinyInteger(string $column, bool $autoIncrement = false)
Create a new unsigned tiny integer (1-byte) column on the table.
at line 722
Fluent
unsignedSmallInteger(string $column, bool $autoIncrement = false)
Create a new unsigned small integer (2-byte) column on the table.
at line 734
Fluent
unsignedMediumInteger(string $column, bool $autoIncrement = false)
Create a new unsigned medium integer (3-byte) column on the table.
at line 746
Fluent
unsignedBigInteger(string $column, bool $autoIncrement = false)
Create a new unsigned big integer (8-byte) column on the table.
at line 759
Fluent
float(string $column, int $total = 8, int $places = 2)
Create a new float column on the table.
at line 772
Fluent
double(string $column, int|null $total = null, int|null $places = null)
Create a new double column on the table.
at line 785
Fluent
decimal(string $column, int $total = 8, int $places = 2)
Create a new decimal column on the table.
at line 798
Fluent
unsignedDecimal(string $column, int $total = 8, int $places = 2)
Create a new unsigned decimal column on the table.
at line 868
Fluent
dateTime(string $column, int $precision = 0)
Create a new date-time column on the table.
at line 880
Fluent
dateTimeTz(string $column, int $precision = 0)
Create a new date-time column (with time zone) on the table.
at line 904
Fluent
timeTz(string $column, int $precision = 0)
Create a new time column (with time zone) on the table.
at line 916
Fluent
timestamp(string $column, int $precision = 0)
Create a new timestamp column on the table.
at line 928
Fluent
timestampTz(string $column, int $precision = 0)
Create a new timestamp (with time zone) column on the table.
at line 939
void
timestamps(int $precision = 0)
Add nullable creation and update timestamps to the table.
at line 954
void
nullableTimestamps(int $precision = 0)
Add nullable creation and update timestamps to the table.
Alias for self::timestamps().
at line 965
void
timestampsTz(int $precision = 0)
Add creation and update timestampTz columns to the table.
at line 979
Fluent
softDeletes(string $column = 'deleted_at', int $precision = 0)
Add a "deleted at" timestamp for the table.
at line 1068
Fluent
point(string $column, int|null $srid = null)
Create a new point column on the table.
at line 1101
Fluent
geometryCollection(string $column)
Create a new geometrycollection column on the table.
at line 1123
Fluent
multiLineString(string $column)
Create a new multilinestring column on the table.
at line 1146
void
morphs(string $name, string|null $indexName = null)
Add the proper columns for a polymorphic table.
at line 1162
void
nullableMorphs(string $name, string|null $indexName = null)
Add nullable columns for a polymorphic table.
at line 1190
protected Fluent
indexCommand(string $type, string|array $columns, string $index, string|null $algorithm = null)
Add a new index command to the blueprint.
at line 1212
protected Fluent
dropIndexCommand(string $command, string $type, string|array $index)
Create a new drop index command on the blueprint.
at line 1233
protected string
createIndexName(string $type, array $columns)
Create a default index name for the table.
at line 1248
Fluent
addColumn(string $type, string $name, array $parameters = [])
Add a new column to the blueprint.
at line 1263
$this
removeColumn(string $name)
Remove a column from the schema blueprint.
at line 1279
protected Fluent
addCommand(string $name, array $parameters = [])
Add a new command to the blueprint.
at line 1293
protected Fluent
createCommand(string $name, array $parameters = [])
Create a new Fluent command.
at line 1303
string
getTable()
Get the table the blueprint describes.