UsersTable
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
The User model configured for the application.
The name of the users table the package should attach itself to.
The primary key column of the users table.
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.
Assert that the users table exists before a migration references it.
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]).
at line 88
static string
name()
The name of the users table the package should attach itself to.
at line 100
static string
keyName()
The primary key column of the users table.
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.
at line 136
static string
requireTable(string $migration)
Assert that the users table exists before a migration references it.
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.