Skip to content

"Expected MatanYadaev\EloquentSpatial\GeometryCast, string given" while swapping two records #79

@RahulKRaj7

Description

@RahulKRaj7

Hi!,
i am trying to implement draft functionality on model. in that while trying to swap two records. i am facing Expected MatanYadaev\EloquentSpatial\GeometryCast, string given this type of error.
Updating location data doesn't work.
Below is the snapshot of swapping code.

$oldAttributes = $published?->getAttributes() ?? [];
        $newAttributes = $this->getAttributes();
        Arr::forget($oldAttributes, $this->getKeyName());
        Arr::forget($newAttributes, $this->getKeyName());

        $published->forceFill($newAttributes);
        $this->forceFill($oldAttributes);

The field is casted in model as
location' => Point::class,

in the migration the field is created as
$table->point('location')->nullable();

Using Laravel-Drafts package for implementing draft functionality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions