shlogg · Early preview
Paul Redmond @paulredmond

Laravel V11.10 Released With New Features And Updates

Laravel v11.10 released with updateOrInsert() callback, soft-deleted models support & more. See release notes for full details.

This week, the Laravel team released v11.10, with the ability to pass a callback to updateOrInsert, support for soft-deleted models with explicit route model binding, and more.
#Allow Passing a Callback to updateOrInsert()
Mark Eriksson contributed the ability to pass a callback as the second argument to the updateOrInsert() query builder method. Within the callback, the boolean $exists variable is passed so you can write logic to update specific columns based on whether the record exists or not:
DB::table('users')->updateOrInsert(  ['user_id' => $user_id],  function ($exists) use ($data) {...