You necessarily have a place in your code where you update this property.
Can you show the entire update() function in your controller ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, i'm trying to NOT update the input datetime-local value when i submit my form. But everytime i send form, i always see post->published_at value updated with current date , even if published_at input is not touched
Post.php
protected $dates = ['published_at'];
protected $casts = [
'published_at' => 'datetime',
];
PostController.php
$inputPublishedAt = $req->input('published_at');
if (!empty($inputPublishedAt)) {
$newPublishedAt = Carbon::parse($inputPublishedAt)->setTimezone($post->published_at->timezone);
if (!$post->published_at->startOfHour()->eq($newPublishedAt->startOfHour())) {
$post->published_at = $newPublishedAt;
} else {
// not change $post->published_at
}
}
value on database: 2024-12-14 14:03:20
what i'm trying to do is to not update the value if the request->published_at and $post->published_at are different for a maximum of one hour , anyone can help ? thank you
Please or to participate in this conversation.