How to check if row is soft-deleted in Eloquent?

How to check if row is soft-deleted in Eloquent?

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

The deleted_at Attribute and Soft Deletes in Eloquent

When working with Laravel's soft delete feature, developers often find themselves asking a specific question after retrieving a model instance: how do I determine if this specific object has been soft-deleted? The most common scenario involves fetching a record while including trashed items, typically using Thing::withTrashed()->find($id). Once that $thing object is in your local scope, you need a reliable way to check its state without querying the database again.

The standard approach, as noted in existing discussions around Laravel 5.1 and subsequent versions, relies on inspecting the underlying timestamp column directly. Since soft deletes function by setting the deleted_at column on the model's table rather than removing the row physically, that attribute is the primary indicator of the record's state.

You can check the status with a straightforward null comparison:

if ($thing->deleted_at !== null) {
    // The model is soft-deleted
} else {
    // The model is active
}

This logic holds true regardless of how the model was retrieved. Whether you loaded it via find(), get(), or a eager loading relationship, if the deleted_at timestamp contains a value, the record is considered trashed within the context of soft deletes.

However, relying solely on direct property access raises questions about API consistency and code clarity. In many ORM implementations, developers expect a semantic method like isDeleted() to exist, similar to how we check for active states or other model conditions. While Laravel does not provide a built-in isDeleted() magic method in its core Eloquent model class, the underlying mechanism is robust enough that direct property inspection remains the idiomatic solution within the framework's ecosystem.

Handling the Context of Trashed Items

It is crucial to understand that the deleted_at attribute only signifies a soft delete when the model is loaded with trashed items enabled. If you retrieve a model using standard queries like Thing::find($id), Laravel automatically filters out any rows where deleted_at is not null. In those cases, if you receive an empty result, the item was deleted, but you won't have an object to inspect.

When you explicitly use withTrashed(), you force Eloquent to include records with non-null timestamps in your results set. At this point, the deleted_at property becomes the definitive source of truth for that specific instance's lifecycle state. This distinction ensures that your application logic can differentiate between "record doesn't exist anymore" (standard delete or filtered out) and "record exists but is marked as deleted" (soft delete).

Avoiding Common Pitfalls

A frequent mistake occurs when attempting to use deleted_at on a model instance that was loaded via a standard query without withTrashed(). If the item was soft-deleted in the database, calling Thing::find($id) will return null or throw an exception depending on your configuration, meaning there is no object to check. You must ensure the retrieval strategy matches the inspection strategy.

Another edge case involves eager loading relationships. If you are eager loading a relationship that has also been soft-deleted, the parent model's deleted_at property remains unaffected. The child model instance might have its own deleted_at value, but checking the parent does not reveal the state of the relationship unless you specifically inspect the relationship collection or the related model instances themselves.

If you require a more expressive API in your specific application layer, you can create an extension method on your Model trait or abstract base class:

public function isSoftDeleted()
{
    return $this->deleted_at !== null;
}

Adding this helper to your base model allows you to write if ($thing->isSoftDeleted()) which improves readability while maintaining the technical accuracy of checking the timestamp. This pattern keeps your logic clean without fighting against Laravel's core design, which prefers direct attribute access for internal state management.

Our network