final class Table implements Stringable (View source)

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
nova(string|null $suffix = null)

Get the Nova resource name from table name.

string
title(string|null $suffix = null)

Get the title for Nova resource 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.

bool
hasTimestamps()

Let it know if the table has timestamps.

Column|null
getPrimaryColumn()

Get the primary key column.

string
__toString()

Class magic method to get the real table name.

Details

__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

array getColumns()

Get column array.

Return Value

array

The method returns \Cable8mm\Xeed\Column array

array getForeignKeys()

Get key array.

Return Value

array

The method returns \Cable8mm\Xeed\Key array

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

string nova(string|null $suffix = null)

Get the Nova resource name from table name.

Parameters

string|null $suffix

Return Value

string

The method returns the NovaResourceName

Examples

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

string title(string|null $suffix = null)

Get the title for Nova resource name from table name.

Parameters

string|null $suffix

Return Value

string

The method returns the title for NovaResource name

Examples

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

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

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

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

bool hasTimestamps()

Let it know if the table has timestamps.

Return Value

bool

Column|null getPrimaryColumn()

Get the primary key column.

Return Value

Column|null

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