Example of Local scopes in driesvints/driesvints.com

File app/Models/Post.php (link to Github)
use Illuminate\Database\Eloquent\Model;

final class Post extends Model
{
    public function scopePublished(Builder $query): Builder
    {
        return $query->where('published_at', '<=', now());
    }
}
File app/Http/Controllers/BlogController.php (link to Github)
use App\Models\Post;

final class BlogController
{
    public function __invoke()
    {
        $posts = Post::published()->orderByDesc('published_at')->get();

        return view('blog', compact('posts'));
    }
}

Additional resources on local scopes: