Skip to content

Custom Attribute File Field Type Fails to Save Due to Strict Type Comparison in AttributeData #2091

@Huncsuga

Description

@Huncsuga
  • Lunar version: 1.0.0-beta.6
  • Laravel Version: 11.35.1
  • PHP Version: 8.3.15
  • Database Driver & Version: MySQL 8

Expected Behaviour:

When creating a custom attribute file field type by following the documentation, the file should be correctly saved, and its reference should be stored in the database.

Actual Behaviour:

When attempting to save a custom attribute file field type, an error occurs. The issue seems to stem from the AttributeData class, specifically in the ->mutateDehydratedStateUsing method. There is an if condition that checks:
if ($attribute->type == FileFieldType::class)
Since a custom attribute file field type is not strictly equal to FileFieldType::class, this condition does not execute.

Steps To Reproduce:

  1. Follow the Lunar documentation to create a custom attribute field type for a file upload.
  2. Attempt to save a record with this custom file field type.
  3. Observe that an error occurs because the if condition does not account for custom file field types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions