I've never tried setting date-time property to string. Maybe that is the reason why it is causing issues.
Try
$notice->resp_received = Carbon::createFromFormat('Y-m-d', $request->resp_received);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a weird one happening. I have two fields, one of which ('response') is getting updated, the other ('resp_received') is not. I've tried both of the following in my controller and get the same result -- 'response' gets set but 'resp_received' does not.
Option 1:
// Response received datestamp
if ($request->update_type === 'response_received_datestamp') {
$notice->resp_received = $request->resp_received;
$notice->response = $request->response;
return back()->with('success', 'Response updated!');
}
Option 2:
// Response received datestamp
if ($request->update_type === 'response_received_datestamp') {
$notice->update([
'resp_received' => $request->resp_received,
'response' => $request->response
]);
return back()->with('success', 'Response updated!');
}
In my model:
protected $fillable = [
...,
'response',
'resp_received',
...
];
protected $dates = [
...
'resp_received',
...
];
And the form from my blade file:
<div class="modal fade row" id="response_received_datestamp_{{ $notice->id }}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Set Response Received</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<form method="POST" action="{{ route('notices.update', $notice) }}">
@csrf
@method('PATCH')
<div class="modal-body">
<input type="hidden" value="response_received_datestamp" name="update_type">
<div class="form-group">
<label for="resp_received">Response Received</label>
<input type="date" id="resp_received" name="resp_received" class="form-control" value="{{ \Carbon\Carbon::now()->format('Y-m-d') }}">
</div>
<label for="response">Enter Response</label>
<textarea class="form-control" id="response" name="response"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-success">Set Response Received</button>
</div>
</form>
</div>
</div>
</div>
Any thoughts would be greatly appreciated.
I wish I could blame it on something other than poor sleep but it is what it is.
I had mistakenly placed an if further up in the code that handles editing just the 'response' request. With it now in the proper position option 2 is working as it should.
@snapey, yes my mistake for not showing the save() and including the redirect. That's what tipped me off. @bugsysha and @siangboon, I did try your suggestions before realizing my stupidity. Thanks for that.
Please or to participate in this conversation.