class ModelIdentifier

NOTE: Do not use constructor property promotion here.

The order these properties are declared in is part of the serialized output, and Laravel expects that exact order. If this class is switched to constructor property promotion, PHP will change the property declaration order and the serialized string will no longer match Laravel.

Keep these properties explicitly declared in this exact order: class, id, relations, connection, collectionClass.

Properties

static protected bool $useMorphMap

Use the Relation morphMap for a Model's name when serializing.

string|null $class

The class name of the model, or its morph-map alias when enabled.

mixed $id

The unique identifier of the model.

array<int, string> $relations

The relationships loaded on the model.

string|null $connection

The connection name of the model.

null|Collection> $collectionClass

The class name of the model collection.

Methods

__construct(string|null $class, mixed $id, array $relations, string|null $connection = null)

Create a new model identifier.

useCollectionClass(string|null $collectionClass)

Specify the collection class that should be used when serializing / restoring collections.

string|null
getClass()

Get the fully-qualified class name of the Model.

static void
useMorphMap(bool $useMorphMap = true)

Indicate whether to use the relational morph-map when serializing Models.

static void
flushState()

Flush all static state.

Details

at line 66
__construct(string|null $class, mixed $id, array $relations, string|null $connection = null)

Create a new model identifier.

Parameters

string|null $class
mixed $id

this may be either a single ID or an array of IDs

array $relations

the relationships loaded on the model

string|null $connection

the connection name of the model

at line 83
ModelIdentifier useCollectionClass(string|null $collectionClass)

Specify the collection class that should be used when serializing / restoring collections.

Parameters

string|null $collectionClass

Return Value

ModelIdentifier

at line 93
string|null getClass()

Get the fully-qualified class name of the Model.

Return Value

string|null

at line 108
static void useMorphMap(bool $useMorphMap = true)

Indicate whether to use the relational morph-map when serializing Models.

Boot-only. The flag persists in a static property for the worker lifetime and applies to every model identifier serialization across all coroutines.

Parameters

bool $useMorphMap

Return Value

void

at line 116
static void flushState()

Flush all static state.

Return Value

void