class MySqlBuilder extends Builder (View source)

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected Connection $connection

The database connection instance.

from  Builder
protected Grammar $grammar

The schema grammar instance.

from  Builder
protected Closure $resolver

The Blueprint resolver callback.

from  Builder
static int|null $defaultStringLength

The default string length for migrations.

from  Builder
static string $defaultMorphKeyType

The default relationship morph key type.

from  Builder
static bool $alwaysUsesNativeSchemaOperationsIfPossible

Indicates whether Doctrine DBAL usage will be prevented if possible when dropping, renaming, and modifying columns.

from  Builder

Methods

static void
macro(string $name, object|callable $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Checks if macro is registered.

static void
flushMacros()

Flush the existing macros.

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.

void
__construct(Connection $connection)

Create a new database Schema manager.

from  Builder
static void
defaultStringLength(int $length)

Set the default string length for migrations.

from  Builder
static void
defaultMorphKeyType(string $type)

Set the default morph key type for migrations.

from  Builder
static void
morphUsingUuids()

Set the default morph key type for migrations to UUIDs.

from  Builder
static void
morphUsingUlids()

Set the default morph key type for migrations to ULIDs.

from  Builder
static void
useNativeSchemaOperationsIfPossible(bool $value = true)

Attempt to use native schema operations for dropping, renaming, and modifying columns, even if Doctrine DBAL is installed.

from  Builder
bool
createDatabase(string $name)

Create a database in the schema.

bool
dropDatabaseIfExists(string $name)

Drop a database from the schema if the database exists.

bool
hasTable(string $table)

Determine if the given table exists.

from  Builder
bool
hasView(string $view)

Determine if the given view exists.

from  Builder
array
getTables()

Get the tables for the database.

array
getTableListing()

Get the names of the tables that belong to the database.

from  Builder
array
getViews()

Get the views for the database.

array
getTypes()

Get the user-defined types that belong to the database.

from  Builder
array
getAllTables() deprecated

Get all of the table names for the database.

bool
hasColumn(string $table, string $column)

Determine if the given table has a given column.

from  Builder
bool
hasColumns(string $table, array $columns)

Determine if the given table has given columns.

from  Builder
void
whenTableHasColumn(string $table, string $column, Closure $callback)

Execute a table builder callback if the given table has a given column.

from  Builder
void
whenTableDoesntHaveColumn(string $table, string $column, Closure $callback)

Execute a table builder callback if the given table doesn't have a given column.

from  Builder
string
getColumnType(string $table, string $column, bool $fullDefinition = false)

Get the data type for the given column name.

from  Builder
array
getColumnListing(string $table)

Get the column listing for a given table.

from  Builder
array
getColumns(string $table)

Get the columns for a given table.

array
getIndexes(string $table)

Get the indexes for a given table.

array
getIndexListing(string $table)

Get the names of the indexes for a given table.

from  Builder
bool
hasIndex(string $table, string|array $index, string|null $type = null)

Determine if the given table has a given index.

from  Builder
array
getForeignKeys(string $table)

Get the foreign keys for a given table.

void
table(string $table, Closure $callback)

Modify a table on the schema.

from  Builder
void
create(string $table, Closure $callback)

Create a new table on the schema.

from  Builder
void
drop(string $table)

Drop a table from the schema.

from  Builder
void
dropIfExists(string $table)

Drop a table from the schema if it exists.

from  Builder
void
dropColumns(string $table, string|array $columns)

Drop columns from a table schema.

from  Builder
void
dropAllTables()

Drop all tables from the database.

void
dropAllViews()

Drop all views from the database.

void
dropAllTypes()

Drop all types from the database.

from  Builder
void
rename(string $from, string $to)

Rename a table on the schema.

from  Builder
bool
enableForeignKeyConstraints()

Enable foreign key constraints.

from  Builder
bool
disableForeignKeyConstraints()

Disable foreign key constraints.

from  Builder
mixed
withoutForeignKeyConstraints(Closure $callback)

Disable foreign key constraints during the execution of a callback.

from  Builder
void
build(Blueprint $blueprint)

Execute the blueprint to build / modify the table.

from  Builder
createBlueprint(string $table, Closure $callback = null)

Create a new command set with a Closure.

from  Builder
getConnection()

Get the database connection instance.

from  Builder
$this
setConnection(Connection $connection)

Set the database connection instance.

from  Builder
void
blueprintResolver(Closure $resolver)

Set the Schema Blueprint resolver callback.

from  Builder
array
getAllViews() deprecated

Get all of the view names for the database.

Details

static void macro(string $name, object|callable $macro)

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

static void flushMacros()

Flush the existing macros.

Return Value

void

static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

void __construct(Connection $connection)

Create a new database Schema manager.

Parameters

Connection $connection

Return Value

void

static void defaultStringLength(int $length)

Set the default string length for migrations.

Parameters

int $length

Return Value

void

static void defaultMorphKeyType(string $type)

Set the default morph key type for migrations.

Parameters

string $type

Return Value

void

Exceptions

InvalidArgumentException

static void morphUsingUuids()

Set the default morph key type for migrations to UUIDs.

Return Value

void

static void morphUsingUlids()

Set the default morph key type for migrations to ULIDs.

Return Value

void

static void useNativeSchemaOperationsIfPossible(bool $value = true)

Attempt to use native schema operations for dropping, renaming, and modifying columns, even if Doctrine DBAL is installed.

Parameters

bool $value

Return Value

void

bool createDatabase(string $name)

Create a database in the schema.

Parameters

string $name

Return Value

bool

bool dropDatabaseIfExists(string $name)

Drop a database from the schema if the database exists.

Parameters

string $name

Return Value

bool

bool hasTable(string $table)

Determine if the given table exists.

Parameters

string $table

Return Value

bool

bool hasView(string $view)

Determine if the given view exists.

Parameters

string $view

Return Value

bool

array getTables()

Get the tables for the database.

Return Value

array

array getTableListing()

Get the names of the tables that belong to the database.

Return Value

array

array getViews()

Get the views for the database.

Return Value

array

array getTypes()

Get the user-defined types that belong to the database.

Return Value

array

array getAllTables() deprecated

deprecated Will be removed in a future Laravel version.

Get all of the table names for the database.

Return Value

array

bool hasColumn(string $table, string $column)

Determine if the given table has a given column.

Parameters

string $table
string $column

Return Value

bool

bool hasColumns(string $table, array $columns)

Determine if the given table has given columns.

Parameters

string $table
array $columns

Return Value

bool

void whenTableHasColumn(string $table, string $column, Closure $callback)

Execute a table builder callback if the given table has a given column.

Parameters

string $table
string $column
Closure $callback

Return Value

void

void whenTableDoesntHaveColumn(string $table, string $column, Closure $callback)

Execute a table builder callback if the given table doesn't have a given column.

Parameters

string $table
string $column
Closure $callback

Return Value

void

string getColumnType(string $table, string $column, bool $fullDefinition = false)

Get the data type for the given column name.

Parameters

string $table
string $column
bool $fullDefinition

Return Value

string

array getColumnListing(string $table)

Get the column listing for a given table.

Parameters

string $table

Return Value

array

array getColumns(string $table)

Get the columns for a given table.

Parameters

string $table

Return Value

array

array getIndexes(string $table)

Get the indexes for a given table.

Parameters

string $table

Return Value

array

array getIndexListing(string $table)

Get the names of the indexes for a given table.

Parameters

string $table

Return Value

array

bool hasIndex(string $table, string|array $index, string|null $type = null)

Determine if the given table has a given index.

Parameters

string $table
string|array $index
string|null $type

Return Value

bool

array getForeignKeys(string $table)

Get the foreign keys for a given table.

Parameters

string $table

Return Value

array

void table(string $table, Closure $callback)

Modify a table on the schema.

Parameters

string $table
Closure $callback

Return Value

void

void create(string $table, Closure $callback)

Create a new table on the schema.

Parameters

string $table
Closure $callback

Return Value

void

void drop(string $table)

Drop a table from the schema.

Parameters

string $table

Return Value

void

void dropIfExists(string $table)

Drop a table from the schema if it exists.

Parameters

string $table

Return Value

void

void dropColumns(string $table, string|array $columns)

Drop columns from a table schema.

Parameters

string $table
string|array $columns

Return Value

void

void dropAllTables()

Drop all tables from the database.

Return Value

void

void dropAllViews()

Drop all views from the database.

Return Value

void

void dropAllTypes()

Drop all types from the database.

Return Value

void

Exceptions

LogicException

void rename(string $from, string $to)

Rename a table on the schema.

Parameters

string $from
string $to

Return Value

void

bool enableForeignKeyConstraints()

Enable foreign key constraints.

Return Value

bool

bool disableForeignKeyConstraints()

Disable foreign key constraints.

Return Value

bool

mixed withoutForeignKeyConstraints(Closure $callback)

Disable foreign key constraints during the execution of a callback.

Parameters

Closure $callback

Return Value

mixed

protected void build(Blueprint $blueprint)

Execute the blueprint to build / modify the table.

Parameters

Blueprint $blueprint

Return Value

void

protected Blueprint createBlueprint(string $table, Closure $callback = null)

Create a new command set with a Closure.

Parameters

string $table
Closure $callback

Return Value

Blueprint

Connection getConnection()

Get the database connection instance.

Return Value

Connection

$this setConnection(Connection $connection)

Set the database connection instance.

Parameters

Connection $connection

Return Value

$this

void blueprintResolver(Closure $resolver)

Set the Schema Blueprint resolver callback.

Parameters

Closure $resolver

Return Value

void

array getAllViews() deprecated

deprecated Will be removed in a future Laravel version.

Get all of the view names for the database.

Return Value

array