[Bug]: DateColumn throws error on NULL values when using date format
nathanmay opened this issue · 5 comments
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
Should be fixed this weekend, have the fix, just need to check that it doesn't impact any of the tests etc
Is now in develop should you wish to test it, should be a new release this weekend.
I plan to do a release tomorrow which will be everything in develop.
Then there's another release coming shortly which adds some Header Action capabilities.
And there's an ArrayColumn which I need to document and write tests for.
At some point I'll add a bleeding-edge branch for anything that isn't ready for release due to docs/tests being missing, as develop does require those to be present.
The fix for this should be in the latest version, if you still have issues, then please re-open the issue/reply/reach out on Discord!