final class Table implements Stringable

Database Table Object.

Methods

__construct(string $name, array|null $columns = [], array|null $foreignKeys = [])

Constructor.

array
getColumns()

Get column array.

array
getForeignKeys()

Get key array.

string
model(string|null $suffix = null)

Get the model name from table name.

string
factory(string|null $suffix = null)

Get the factory name from table name.

string
seeder(string|null $suffix = null)

Get the seeder name from table name.

string
migration()

Get the migration file name from table name.

string
__toString()

Class magic method to get the real table name.

Details

at line 40
__construct(string $name, array|null $columns = [], array|null $foreignKeys = [])

Constructor.

Parameters

string $name

Table name

array|null $columns

Column array[Table]

array|null $foreignKeys

Foreign key array

at line 56
array getColumns()

Get column array.

Return Value

array

The method returns \Cable8mm\Xeed\Column array

at line 66
array getForeignKeys()

Get key array.

Return Value

array

The method returns \Cable8mm\Xeed\Key array

at line 79
string model(string|null $suffix = null)

Get the model name from table name.

Parameters

string|null $suffix

Return Value

string

The method returns the ModelName

Examples

echo (new Table('users'))->model();
//=> User

at line 92
string factory(string|null $suffix = null)

Get the factory name from table name.

Parameters

string|null $suffix

Return Value

string

The method returns the FactoryName

Examples

echo (new Table('users'))->factory();
//=> User

at line 105
string seeder(string|null $suffix = null)

Get the seeder name from table name.

Parameters

string|null $suffix

Return Value

string

The method returns the SeederName

Examples

echo (new Table('users'))->seeder();
//=> User

at line 118
string migration()

Get the migration file name from table name.

Return Value

string

The method returns the migration file name.

Examples

echo (new Table('users'))->migration();
//=> 2024_03_18_135821_create_users_table.php

at line 131
string __toString()

Class magic method to get the real table name.

Return Value

string

The method returns the real table name.

Examples

echo new Table('users');
//=> users