Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fahad's avatar
Level 7

Nullable date that is registered as eloquent carbon date

I have added

 protected $dates = ['schedule_date'];

at my model, but sometime it may be null, in case of null now i am getting error while attempting to update the row.

(1/1) InvalidArgumentException
Data missing

Any help is highly appreciated. Thanks

0 likes
1 reply
fahad's avatar
fahad
OP
Best Answer
Level 7

Ooops, sorry solved. my fault::

instead of writing this logic

 $item->schedule_date = $request->schedule_date ? Carbon::createFromFormat('m-d-Y', $request->schedule_date)->format('Y-m-d') : null;

mistakenly I have written


 $item->schedule_date = $item->schedule_date ? Carbon::createFromFormat('m-d-Y', $request->schedule_date)->format('Y-m-d') : null;

Please or to participate in this conversation.