All packages
Requests for Laravel
Query scopes
use RoundlyConsulting\Requests\Enums\Status;
use RoundlyConsulting\Requests\Models\Request;
Request::query()->withStatus(Status::New)->get();
Request::query()->pending()->get();
Request::query()->approved()->get();
Request::query()->rejected()->get();
Request::query()->cancelled()->get();
Request::query()->expired()->get(); // open + past expires_at
Request::query()->expiringBefore(now()->addDay())->get();
Request::query()->authoredBy($user)->get();| Scope | Matches |
|---|---|
withStatus(Status $status) | Requests in the given status. |
pending() | Status New — open, awaiting a decision. |
approved() / rejected() / cancelled() | Status Approved / Rejected / Cancelled. |
expired() | Still New and past expires_at — the requests due for expiry, not rows already in status Expired. Use withStatus(Status::Expired) for those. |
expiringBefore(CarbonInterface $moment) | Still New with expires_at before the given moment. |
authoredBy(Model $author) | Requests raised by the given author (type + id). |
Combining scopes
Scopes chain with each other and with plain query-builder calls:
// Alice's open claims that lapse within 48 hours:
Request::query()
->authoredBy($alice)
->pending()
->expiringBefore(now()->addHours(48))
->where('type', 'Claim')
->get();On the author side, $user->openRequests(), approvedRequests() and rejectedRequests() give the same filters as relations (Model setup).
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 cryptoBy donating, you agree to our donation terms.
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.