LaravelLaravel17 min read

Query Scopes: Reusable Filters in Models

Create reusable query logic using local scopes in Eloquent models.

Laura Adams
October 6, 2025
2.9k69

Query scopes allow you to define common filters directly in your models.

## Define a scope

```php
public function scopePublished($query) {
  return $query->where('status', 'published');
}
```

## Use it

```php
$posts = Post::published()->latest()->get();
```

Scopes keep controllers clean and logic centralized.

In the next tutorial, we will implement soft deletes.
#Laravel#Eloquent#Intermediate