migrations ​
File: src/Helpers/migrations_helpers.php
Blueprint helper functions that provide standardized field presets for Modularous migration files. They respect the use_big_integers_on_migrations config option to switch between int and bigInt column types.
Integer Type Helpers ​
modularousIncrementsMethod ​
modularousIncrementsMethod(): stringReturns 'bigIncrements' or 'increments' depending on the use_big_integers_on_migrations config flag.
modularousIntegerMethod ​
modularousIntegerMethod(): stringReturns 'bigInteger' or 'integer' depending on the same config flag.
Table Field Presets ​
createDefaultTableFields ​
createDefaultTableFields(Blueprint $table, bool $has_name = true): voidAdds the primary key column using modularousIncrementsMethod(). Minimal base — does not add name, timestamps, or soft deletes.
createDefaultExtraTableFields ​
createDefaultExtraTableFields(
Blueprint $table,
bool $softDeletes = true,
bool $published = true,
bool $publishDates = false,
bool $visibility = false
): voidAdds optional standard columns:
| Parameter | Column added |
|---|---|
$published = true | published (boolean, default false) |
$publishDates = true | publish_start_date, publish_end_date (nullable timestamps) |
$visibility = true | public (boolean, default true) |
| always | created_at, updated_at |
$softDeletes = true | deleted_at |
createDefaultTranslationsTableFields ​
createDefaultTranslationsTableFields(
Blueprint $table,
string $modelName,
string $tableName = null,
string $foreignKey = null
): voidScaffolds a standard *_translations pivot table:
id(increments){model}_id(unsigned integer, foreign key → parent table with CASCADE delete)deleted_at,created_at,updated_atlocale(string 7, indexed)active(boolean, default true)- Unique index on
({model}_id, locale)
Handles long model names (> 18 chars) by using abbreviation() in the foreign key index name.
createDefaultSlugsTableFields ​
createDefaultSlugsTableFields(
Blueprint $table,
string $tableNameSingular,
string $tableNamePlural = null
): voidScaffolds a *_slugs table:
id,{model}_id(foreign key with CASCADE delete),deleted_at, timestampsslug(string),locale(string 7, indexed),active(boolean)
createDefaultRelationshipTableFields ​
createDefaultRelationshipTableFields(
Blueprint $table,
string $table1NameSingular,
string $table2NameSingular,
string $table1NamePlural = null,
string $table2NamePlural = null
): voidScaffolds a many-to-many pivot table with:
{table1}_idand{table2}_idas foreign keys (cascade delete/update)- Composite primary key on both IDs
createDefaultMorphPivotTableFields ​
createDefaultMorphPivotTableFields(
Blueprint $table,
string $modelName = null,
string $tableName = null,
string $morphedTableName = null
): voidScaffolds a morph pivot table (*ables):
{model}_idforeign key → parent table (cascade){morph_name}_type+{morph_name}_idviauuidMorphs()with a named index
createDefaultRevisionsTableFields ​
createDefaultRevisionsTableFields(
Blueprint $table,
string $tableNameSingular,
string $tableNamePlural = null
): voidScaffolds a *_revisions table:
id,{model}_id(foreign → parent, cascade delete),user_id(nullable, set null on delete)created_at,updated_atpayload(JSON)