Skip to content

Boolean fields show inconsistent or blank values in old_values / new_values when toggling between 0 and 1 #41

@tfranssen

Description

@tfranssen

I’m using Laravel Auditing with a TINYINT(1) (non-null) column for a boolean field (e.g. hasTubes). In my Eloquent model, I’ve cast this column to a boolean ('hasTubes' => 'boolean'). When I toggle the field in my Filament form between true (1) and false (0), the audit entries sometimes display the old/new values as 1 or 0, but other times they appear blank (see the screenshot below).

Screenshot

Image

Steps to Reproduce:

  1. Use Laravel Auditing on a model with a TINYINT(1) column for a boolean field (e.g. hasTubes), not nullable, default 0.
  2. Cast it to 'boolean' in the model’s $casts array.
  3. In a Filament form, toggle the field from false to true (or vice versa).
  4. View the audit log – notice that old_values or new_values sometimes show 1 / 0 and sometimes display a blank value.

Expected Behavior:

  • The old_values and new_values should always show 0 or 1 (or true/false) consistently in the audit log, rather than occasionally appearing blank.

Actual Behavior:

  • Occasionally, the audit log for boolean fields appears blank for one of the values, even though the DB is storing 0 or 1 and the model has a correct boolean cast.

Additional Context:

  • Model casting array:
    protected $casts = [
        'hasTubes' => 'boolean',
        // ...
    ];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions