PHP Class Mojopollo\Schema\MakeMigrationJson

Mostra file Open project: mojopollo/laravel-json-schema Class Usage Examples

Protected Properties

Property Type Description
$blueprint Illuminate\Database\Schema\Blueprint The Blueprint instance.
$filesystem Illuminate\Filesystem\Filesystem The Filesystem instance.

Public Methods

Method Description
__construct ( ) New instance
getColumnIndexes ( ) : array Get an array of valid column indexes
getColumnModifiers ( ) : array Get an array of column modifiers from the MySqlGrammar::modifiers property
isValidColumnType ( string $type ) : boolean Checks if supplied string argument is a valid column type
jsonFileToArray ( string $path ) : array Grabs a json file and returns a array
parseProperty ( string $type ) : string Parses the property without the parameters in this method, "string" and "string(50)" should both return as "string"
parseSchema ( array $data, array $only = [] ) : array Parses the schema from the json array into a readable format laravel generators extended understand
setMigrationName ( string $tableName ) : string Creates a migration name from a table name or keeps it intact if a migration name has already been set
validateSchema ( array $data ) : array Validates the schema from the json array and returns an error of syntax errors if any are found

Method Details

__construct() public method

New instance
public __construct ( )

getColumnIndexes() public method

Get an array of valid column indexes
See also: https://laravel.com/docs/5.2/migrations#creating-indexes
See also: https://github.com/laracasts/Laravel-5-Generators-Extended#user-content-foreign-constraints
public getColumnIndexes ( ) : array
return array list of the possible column indexes

getColumnModifiers() public method

Get an array of column modifiers from the MySqlGrammar::modifiers property
public getColumnModifiers ( ) : array
return array Example: unsigned, charset, collate, ...

isValidColumnType() public method

Checks if supplied string argument is a valid column type
See also: https://laravel.com/docs/5.2/migrations#creating-columns
public isValidColumnType ( string $type ) : boolean
$type string Example: string, integer, text, timestamp, etc
return boolean Returns true if valid, otherwise false

jsonFileToArray() public method

Grabs a json file and returns a array
public jsonFileToArray ( string $path ) : array
$path string The path to the json file
return array The parsed array

parseProperty() public method

Parses the property without the parameters in this method, "string" and "string(50)" should both return as "string"
public parseProperty ( string $type ) : string
$type string Example: "string", "string(50)", etc
return string the parsed column type name

parseSchema() public method

Parses the schema from the json array into a readable format laravel generators extended understand
public parseSchema ( array $data, array $only = [] ) : array
$data array The array containing the json output from file
$only array (optional) array containing specific table/migration names to retrieve from the json file
return array The finished parsed schema for use with generators extended

setMigrationName() public method

Creates a migration name from a table name or keeps it intact if a migration name has already been set
public setMigrationName ( string $tableName ) : string
$tableName string The original table name (Example: users, cats, create_users_table)
return string The migration name

validateSchema() public method

Validates the schema from the json array and returns an error of syntax errors if any are found
See also: https://laravel.com/docs/5.2/migrations#creating-columns
See also: https://laravel.com/docs/5.2/migrations#creating-indexes
public validateSchema ( array $data ) : array
$data array The array containing the json output from file
return array Any errors identified for every field schema

Property Details

$blueprint protected_oe property

The Blueprint instance.
protected Blueprint,Illuminate\Database\Schema $blueprint
return Illuminate\Database\Schema\Blueprint

$filesystem protected_oe property

The Filesystem instance.
protected Filesystem,Illuminate\Filesystem $filesystem
return Illuminate\Filesystem\Filesystem