PHP Class Nwidart\Modules\Support\Migrations\SchemaParser

Inheritance: implements Illuminate\Contracts\Support\Arrayable
Show file Open project: nwidart/laravel-modules Class Usage Examples

Protected Properties

Property Type Description
$customAttributes array The array of custom attributes.
$relationshipKeys array The relationship keys.
$schema string The migration schema.

Public Methods

Method Description
__construct ( string | null $schema = null ) Create new instance.
createField ( string $column, array $attributes, $type = 'add' ) : string Create field.
down ( ) : string Render down migration fields.
getAttributes ( string $column, string $schema ) : array Get column attributes.
getColumn ( string $schema ) : string Get column name from schema.
getCustomAttribute ( string $column ) : array Get custom attributes value.
getSchemas ( ) : array Get array of schema.
hasCustomAttribute ( string $column ) : boolean Determine whether the given column is exist in customAttributes array.
parse ( string $schema ) : array Parse a string to array of formatted schema.
render ( ) : string Render the migration to formatted script.
toArray ( ) : array Convert string migration to array.
up ( ) : string Render up migration fields.

Protected Methods

Method Description
addColumn ( integer $key, string $field, string $column ) : string Format field to script.
addRelationColumn ( integer $key, string $field, string $column ) : string Add relation column.
removeColumn ( integer $key, string $field, string $column ) : string Format field to script.

Method Details

__construct() public method

Create new instance.
public __construct ( string | null $schema = null )
$schema string | null

addColumn() protected method

Format field to script.
protected addColumn ( integer $key, string $field, string $column ) : string
$key integer
$field string
$column string
return string

addRelationColumn() protected method

Add relation column.
protected addRelationColumn ( integer $key, string $field, string $column ) : string
$key integer
$field string
$column string
return string

createField() public method

Create field.
public createField ( string $column, array $attributes, $type = 'add' ) : string
$column string
$attributes array
return string

down() public method

Render down migration fields.
public down ( ) : string
return string

getAttributes() public method

Get column attributes.
public getAttributes ( string $column, string $schema ) : array
$column string
$schema string
return array

getColumn() public method

Get column name from schema.
public getColumn ( string $schema ) : string
$schema string
return string

getCustomAttribute() public method

Get custom attributes value.
public getCustomAttribute ( string $column ) : array
$column string
return array

getSchemas() public method

Get array of schema.
public getSchemas ( ) : array
return array

hasCustomAttribute() public method

Determine whether the given column is exist in customAttributes array.
public hasCustomAttribute ( string $column ) : boolean
$column string
return boolean

parse() public method

Parse a string to array of formatted schema.
public parse ( string $schema ) : array
$schema string
return array

removeColumn() protected method

Format field to script.
protected removeColumn ( integer $key, string $field, string $column ) : string
$key integer
$field string
$column string
return string

render() public method

Render the migration to formatted script.
public render ( ) : string
return string

toArray() public method

Convert string migration to array.
public toArray ( ) : array
return array

up() public method

Render up migration fields.
public up ( ) : string
return string

Property Details

$customAttributes protected property

The array of custom attributes.
protected array $customAttributes
return array

$relationshipKeys protected property

The relationship keys.
protected array $relationshipKeys
return array

$schema protected property

The migration schema.
protected string $schema
return string