Skip to content

[Bug]: DateColumn throws error on NULL values when using date format  #1724

@nathanmay

Description

@nathanmay

What happened?

When using a date column and formatting the date output. When a NULL value is recevied an error is thrown. Even when using ->emptyValue('Not Found') as per docs.

How to reproduce the bug

Set columns

public function columns(): array
    {
        return [
            Column::make("Id", "id")
                ->sortable(),
            Column::make("Booking id", "booking.ref")
                ->sortable()
                ->searchable(),
            Column::make("Invoice id", "invoice.inv_number")
                ->sortable()
                ->searchable(),
            Column::make("Staff id", "staff.first_name")
                ->sortable()
                ->searchable(),
            DateColumn::make("Paid date", "paid_date")
                ->sortable()
                ->emptyValue('NOT PAID YET')
                ->outputFormat('d/m/Y'),
            Column::make('Actions')
                ->label(
                    fn($row, Column $column) => view('livewire.commission.commission-table-actions')->with(
                        [
                            'id' => $row->id,
                        ]
                    )
                )->html(),
        ];
    }

Have record in Databse that is NULL.

Error is thrown:

Carbon\Factory::hasFormatWithModifiers(): Argument #1 ($date) must be of type string, null given, called in C:\laragon\www\pems\vendor\nesbot\carbon\src\Carbon\Traits\Comparison.php on line 822

Package Version

3.2.5

PHP Version

8.2.x

Laravel Version

11.8.0

Alpine Version

No response

Theme

Tailwind 3.x

Notes

Running Livewire 3.5

Error Message

Carbon\Factory::hasFormatWithModifiers(): Argument #1 ($date) must be of type string, null given, called in C:\laragon\www\pems\vendor\nesbot\carbon\src\Carbon\Traits\Comparison.php on line 822

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions