LaravelLaravel15 min read

Query Scopes: Reusable Filters in Models

Create reusable query logic using local scopes in Eloquent models.

Laura Adams
Oct 6, 2025
3,597158

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