final class Column implements Stringable (View source)

Database Column Object.

Methods

__construct(string $field, string $type, bool $unsigned = false, bool $autoIncrement = false, bool $notNull = false, bool $primaryKey = false, string|null $bracket = null, string|null $default = null, string|null $extra = null)

Column constructor.

array
toArray()

Get column information array.

static Column
make(string $field, string $type, bool $unsigned = false, bool $autoIncrement = false, bool $notNull = false, bool $primaryKey = false, string|null $bracket = null, string|null $default = null, string|null $extra = null)

Create a instance.

string
fake()

Get the row string form database factory, then return the string for Seeder class.

string
migration()

Get the row string for migration file, then return the string for migration class.

string
novaField()

Get the row string for migration file, then return the string for migration class.

string
title()

Get the title for Nova field title from column name.

string
__toString()

Class magic method to get the instance information for a Exception

string|null
cast()

No description

Details

__construct(string $field, string $type, bool $unsigned = false, bool $autoIncrement = false, bool $notNull = false, bool $primaryKey = false, string|null $bracket = null, string|null $default = null, string|null $extra = null)

Column constructor.

Parameters

string $field

Name of the column

string $type

Type of the column

bool $unsigned

Nullable flag

bool $autoIncrement

Nullable flag

bool $notNull

Nullable flag

bool $primaryKey

Key of the column

string|null $bracket

Length or something of the column

string|null $default

Default value

string|null $extra

Extra information of the column

array toArray()

Get column information array.

Return Value

array

The method returns column information array

static Column make(string $field, string $type, bool $unsigned = false, bool $autoIncrement = false, bool $notNull = false, bool $primaryKey = false, string|null $bracket = null, string|null $default = null, string|null $extra = null)

Create a instance.

Parameters

string $field

Name of the column

string $type

Type of the column

bool $unsigned

Nullable flag

bool $autoIncrement

Nullable flag

bool $notNull

Nullable flag

bool $primaryKey

Key of the column

string|null $bracket

Length or something of the column

string|null $default

Default value

string|null $extra

Extra information of the column

Return Value

Column

string fake()

Get the row string form database factory, then return the string for Seeder class.

Return Value

string

The method returns a Seeder class row string

string migration()

Get the row string for migration file, then return the string for migration class.

Return Value

string

The method returns a Migration class row string

string novaField()

Get the row string for migration file, then return the string for migration class.

Return Value

string

The method returns a Migration class row string

string title()

Get the title for Nova field title from column name.

Return Value

string

The method returns the title for Nova field title

Examples

echo (new Column(['username', 'varchar']))->title();
//=> Username

string __toString()

Class magic method to get the instance information for a Exception

Return Value

string

The method returns the instance information for a Exception

string|null cast()

No description

Return Value

string|null