Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,13 @@ protected function casts(): array
'password' => 'hashed',
];
}

/** code for issue https://github.com/laravel/framework/issues/57689#issuecomment-3509206190 */
public static function boot(): void
{
parent::boot();
static::updated(function (BaseModel $baseModel): void {
$baseModel->setUpdatedAt(Carbon::now()->addYear()->format($baseModel::CREATED_AT_FORMAT));
});
}
}
7 changes: 7 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
$user = \App\Models\User::query()->firstOrFail();

$user->update(['name' => 'test name']);


dd('User is dirty: ' . (int)$user->isDirty() . ' : ' . $user->updated_at);

return view('welcome');
});