class DataCollectionEloquentCast extends AbstractDataEloquentCast implements CastsAttributes

Constants

protected DEFAULT_STORED_VALUE

Properties

protected DataConfig $dataConfig from  AbstractDataEloquentCast
protected DataClassRepository $dataClasses from  AbstractDataEloquentCast
protected DataTransformer $dataTransformer from  AbstractDataEloquentCast

Methods

__construct(string $dataClass, string $dataCollectionClass = DataCollection::class, array $arguments = [])

Create a data collection Eloquent cast.

bool
compare(Model $model, string $key, mixed $firstValue, mixed $secondValue)

Compare two stored data representations.

bool
isAbstractClassCast()

Determine if the stored value uses an abstract-class envelope.

resolveMorphedData(Model $model, string $key, array $payload)

Resolve data from a strict abstract-class envelope.

array
createMorphEnvelope(BaseData&TransformableData $data, array $payload)

Wrap transformed data in its enforced abstract-class envelope.

bool
isEncrypted()

Determine if the stored value is encrypted.

array|null
decode(Model $model, string $key, mixed $value)

Decode one stored representation through Eloquent's JSON codec.

mixed
get(Model $model, string $key, mixed $value, array $attributes)

Transform the stored attribute into a data collection.

mixed
set(Model $model, string $key, mixed $value, array $attributes)

Transform a data collection into its stored representation.

Details

at line 35
__construct(string $dataClass, string $dataCollectionClass = DataCollection::class, array $arguments = [])

Create a data collection Eloquent cast.

Parameters

string $dataClass
string $dataCollectionClass
array $arguments

bool compare(Model $model, string $key, mixed $firstValue, mixed $secondValue)

Compare two stored data representations.

Parameters

Model $model
string $key
mixed $firstValue
mixed $secondValue

Return Value

bool

protected bool isAbstractClassCast()

Determine if the stored value uses an abstract-class envelope.

Return Value

bool

protected BaseData resolveMorphedData(Model $model, string $key, array $payload)

Resolve data from a strict abstract-class envelope.

Parameters

Model $model
string $key
array $payload

Return Value

BaseData

protected array createMorphEnvelope(BaseData&TransformableData $data, array $payload)

Wrap transformed data in its enforced abstract-class envelope.

Parameters

BaseData&TransformableData $data
array $payload

Return Value

array

protected bool isEncrypted()

Determine if the stored value is encrypted.

Return Value

bool

protected array|null decode(Model $model, string $key, mixed $value)

Decode one stored representation through Eloquent's JSON codec.

Parameters

Model $model
string $key
mixed $value

Return Value

array|null

at line 49
mixed get(Model $model, string $key, mixed $value, array $attributes)

Transform the stored attribute into a data collection.

Parameters

Model $model
string $key
mixed $value
array $attributes

Return Value

mixed

at line 90
mixed set(Model $model, string $key, mixed $value, array $attributes)

Transform a data collection into its stored representation.

Parameters

Model $model
string $key
mixed $value
array $attributes

Return Value

mixed