<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/pessimistic-locking-in-laravel-eloquent-with-refreshforupdate--ukfzaytca" -->

---
title: Pessimistic Locking in Laravel Eloquent with...
description: Laravel 13.27 introduces refreshForUpdate() on Eloquent models, combining refresh() and lockForUpdate() into a single call. The method reloads a model by its...
canonical: https://daily.dev/posts/pessimistic-locking-in-laravel-eloquent-with-refreshforupdate--ukfzaytca
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Pessimistic Locking in Laravel Eloquent with refreshForUpdate() | daily.dev
og:description: Laravel 13.27 introduces refreshForUpdate() on Eloquent models, combining refresh() and lockForUpdate() into a single call. The method reloads a model by its...
og:url: https://daily.dev/posts/pessimistic-locking-in-laravel-eloquent-with-refreshforupdate--ukfzaytca
og:image: https://api.daily.dev/og/posts/UKFzaytcA.png
og:image:alt: Pessimistic Locking in Laravel Eloquent with refreshForUpdate()
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Pessimistic Locking in Laravel Eloquent with refreshForUpdate()

**[Laravel News](https://daily.dev/sources/ln)** · 2 min read · 20 upvotes · 1 comments

## Summary

Laravel 13.27 introduces refreshForUpdate() on Eloquent models, combining refresh() and lockForUpdate() into a single call. The method reloads a model by its primary key with FOR UPDATE applied, routing through useWritePdo() so a read replica cannot serve a stale lock, then replaces attributes and reloaded relations in place. This simplifies patterns like decrementing stock inside a transaction, replacing the previous approach of re-querying the model manually with lockForUpdate() and findOrFail().

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://laravel-news.com/laravel-refresh-for-update>

## Questions this post answers

### What does refreshForUpdate() do in Laravel Eloquent?

It reloads an Eloquent model instance by its primary key with a FOR UPDATE lock applied, updating the instance in place rather than requiring a fresh query. Introduced in Laravel 13.27, it reuses the refreshUsingQuery() helper behind refresh(), routes through useWritePdo() to avoid a stale read replica, reloads relations, and syncs original attribute state.

_Track Laravel's Eloquent locking additions like this one on daily.dev as your codebase upgrades._

### How do I take a pessimistic lock on an Eloquent model without requerying it by key?

Call refreshForUpdate() directly on the model instance instead of manually calling lockForUpdate() and findOrFail() inside a transaction. For example, replacing Product::query()->lockForUpdate()->findOrFail($product->getKey()) with $product->refreshForUpdate() achieves the same row lock while reusing the existing instance, useful for patterns like safely decrementing stock.

_Developers refactoring transactional stock or inventory logic can follow Laravel Eloquent updates via daily.dev._

### Who contributed the refreshForUpdate() method to Laravel and where was it merged?

The method was contributed by developer stevebauman and merged into the Laravel framework via pull request #61247, shipping as part of Laravel 13.27.

_Follow contributor-driven Laravel framework changes like this one through daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@agustinbarrientos** · 0 upvotes

> Can `refreshForUpdate()` preserve tenant isolation when ownership lives in a global scope?

---

Tags: [#backend](https://daily.dev/tags/backend), [#php](https://daily.dev/tags/php), [#laravel](https://daily.dev/tags/laravel)

[View this post on daily.dev](https://daily.dev/posts/pessimistic-locking-in-laravel-eloquent-with-refreshforupdate--ukfzaytca)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Pessimistic Locking in Laravel Eloquent with refreshForUpdate()","url":"https://daily.dev/posts/pessimistic-locking-in-laravel-eloquent-with-refreshforupdate--ukfzaytca","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/pessimistic-locking-in-laravel-eloquent-with-refreshforupdate--ukfzaytca"},"datePublished":"2026-08-28T13:06:53.660Z","dateModified":"2026-09-13T19:09:23.522Z","description":"Laravel 13.27 introduces refreshForUpdate() on Eloquent models, combining refresh() and lockForUpdate() into a single call. The method reloads a model by its...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/676500e29798a3c2aefe3abc8ac70507?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/676500e29798a3c2aefe3abc8ac70507?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Laravel News","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Laravel News","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/ln","url":"https://daily.dev/sources/ln"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/pessimistic-locking-in-laravel-eloquent-with-refreshforupdate--ukfzaytca","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":20},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"backend,php,laravel","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Laravel News","item":"https://daily.dev/sources/ln"},{"@type":"ListItem","position":3,"name":"Pessimistic Locking in Laravel Eloquent with refreshForUpdate()"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/pessimistic-locking-in-laravel-eloquent-with-refreshforupdate--ukfzaytca","comment":[{"@type":"Comment","text":"Can refreshForUpdate() preserve tenant isolation when ownership lives in a global scope?","datePublished":"2026-08-30T11:38:01.245Z","url":"https://daily.dev/posts/UKFzaytcA#c-OAk4L5JVB","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/pessimistic-locking-in-laravel-eloquent-with-refreshforupdate--ukfzaytca#faq","mainEntity":[{"@type":"Question","name":"What does refreshForUpdate() do in Laravel Eloquent?","acceptedAnswer":{"@type":"Answer","text":"It reloads an Eloquent model instance by its primary key with a FOR UPDATE lock applied, updating the instance in place rather than requiring a fresh query. Introduced in Laravel 13.27, it reuses the refreshUsingQuery() helper behind refresh(), routes through useWritePdo() to avoid a stale read replica, reloads relations, and syncs original attribute state. Track Laravel's Eloquent locking additions like this one on daily.dev as your codebase upgrades."}},{"@type":"Question","name":"How do I take a pessimistic lock on an Eloquent model without requerying it by key?","acceptedAnswer":{"@type":"Answer","text":"Call refreshForUpdate() directly on the model instance instead of manually calling lockForUpdate() and findOrFail() inside a transaction. For example, replacing Product::query()-\u003elockForUpdate()-\u003efindOrFail($product-\u003egetKey()) with $product-\u003erefreshForUpdate() achieves the same row lock while reusing the existing instance, useful for patterns like safely decrementing stock. Developers refactoring transactional stock or inventory logic can follow Laravel Eloquent updates via daily.dev."}},{"@type":"Question","name":"Who contributed the refreshForUpdate() method to Laravel and where was it merged?","acceptedAnswer":{"@type":"Answer","text":"The method was contributed by developer stevebauman and merged into the Laravel framework via pull request #61247, shipping as part of Laravel 13.27. Follow contributor-driven Laravel framework changes like this one through daily.dev."}}]}
```

