---
title: "Querying — Appointments for Laravel | Roundly"
description: "Query scopes for upcoming, past, overlapping and per-participant appointments, plus status filters and ordering."
url: https://roundly-consulting.com/open-source/docs/appointments-for-laravel/querying
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Appointments for Laravel](https://roundly-consulting.com/open-source/docs/appointments-for-laravel.md)

# Querying

The Appointment model ships scopes for the common schedule queries:

```php
use RoundlyConsulting\Appointments\Enums\Status;
use RoundlyConsulting\Appointments\Models\Appointment;

Appointment::query()->upcoming()->forParticipant($user)->ordered()->get();
Appointment::query()->between($from, $to)->get();
Appointment::query()->overlapping($start, $end)->get();
Appointment::query()->withStatus(Status::Confirmed, Status::Completed)->get();
Appointment::query()->past()->get();
```

| Scope | Filter |
| --- | --- |
| `upcoming()` | starts\_at at or after now. |
| `past()` | starts\_at before now. |
| `between($from, $to)` | starts\_at between the two instants, inclusive. |
| `overlapping($start, $end)` | Starts before $end and ends after $start (or has no end). Touching ranges don’t overlap. |
| `withStatus(Status ...$statuses)` | Any of the given statuses — variadic. |
| `forParticipant(Model $participant)` | Appointments the given model takes part in. |
| `ordered()` | Ordered by starts\_at, earliest first. |
| `withinRadius(Coordinates $center, float $km)` | Venue inside the radius’s bounding box — from geolocation-for-laravel. |

## Per-model schedules

Because HasAppointments returns a query builder, the same scopes chain off any participant model:

```php
// the same scopes chain off HasAppointments
$user->appointments()->upcoming()->withStatus(Status::Confirmed)->ordered()->get();
$room->appointments()->overlapping($start, $end)->exists();
```

The time scopes compare against the UTC columns, so their Carbon arguments may be in any timezone. Soft-deleted appointments are excluded by Eloquent’s SoftDeletes scope, as everywhere else in Laravel.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/appointments-for-laravel.md)
