class UsersTable

Resolves the application's users table for the package migrations.

The package extends the application's users table, it does not own it. This helper resolves the table from the configured User model, asserts that the application has created it, and mirrors its primary key definition so that foreign keys pointing at it are always type compatible.

Methods

static string|null
model()

The User model configured for the application.

static string
name()

The name of the users table the package should attach itself to.

static string
keyName()

The primary key column of the users table.

static bool
isPackageOwned()

Whether the resolved users table belongs to the package rather than to the application. Only a package owned table may be created by the package migrations.

static string
requireTable(string $migration)

Assert that the users table exists before a migration references it.

static void
matchUserId(Blueprint $table, string $column, string $usersTable)

Add a column to the blueprint that can hold, and be constrained against, the primary key of the users table.

Details

at line 71
static string|null model()

The User model configured for the application.

Handles both the string format ('App\Models\User') and the legacy array format ([7 => App\User::class, 8 => App\Models\User::class]).

Return Value

string|null

at line 88
static string name()

The name of the users table the package should attach itself to.

Return Value

string

at line 100
static string keyName()

The primary key column of the users table.

Return Value

string

at line 114
static bool isPackageOwned()

Whether the resolved users table belongs to the package rather than to the application. Only a package owned table may be created by the package migrations.

Return Value

bool

at line 136
static string requireTable(string $migration)

Assert that the users table exists before a migration references it.

Parameters

string $migration

Migration requiring the table, used in the error message.

Return Value

string

The users table name.

Exceptions

RuntimeException

at line 172
static void matchUserId(Blueprint $table, string $column, string $usersTable)

Add a column to the blueprint that can hold, and be constrained against, the primary key of the users table.

Laravel 11 reports the native database type, so the column type has to be matched exactly: MySQL will reject a foreign key between char(36) and varchar(36), or between signed and unsigned integers.

Parameters

Blueprint $table
string $column
string $usersTable

Return Value

void

Exceptions

RuntimeException