NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages

RoundlyConsulting\RefreshTokens\Models\RefreshToken is a regular Eloquent model with SoftDeletes and Prunable:

use RoundlyConsulting\RefreshTokens\Models\RefreshToken;

RefreshToken::query()->ownedBy($user)->active()->get();     // live sessions
RefreshToken::query()->ownedBy($user)->expired()->count();  // expired rows
RefreshToken::query()->forFamily($familyId)->get();         // every row of one session

$row->isUsable();          // not revoked and not yet expired
$row->sessionStartedAt();  // CarbonImmutable — when the family began
$row->owner;               // MorphTo — the User, Client, …
$row->revoked_reason;      // ?RevocationReason
$row->meta;                // ?array — session metadata
  • Scopes — active(), expired(), forFamily($id) (lowercases the id) and ownedBy($owner) (morph class and key).
  • Helpers — isUsable(), sessionStartedAt() (falls back to created_at on rows that predate the column) and owner() (MorphTo).
  • Casts — expires_at, revoked_at, family_started_at and absolute_expires_at to immutable datetimes; meta to array; is_bot to boolean; device_type per device_type_cast; revoked_reason to RevocationReason.
  • Hidden — token_hash and access_reference.

Swapping the model

Extend the package model and point refresh-tokens.model at your subclass. A configured class that does not extend the package model falls back to the packaged one:

namespace App\Models;

use RoundlyConsulting\RefreshTokens\Models\RefreshToken as BaseRefreshToken;

class RefreshToken extends BaseRefreshToken
{
    // your own scopes, relations, observers …
}

// config/refresh-tokens.php
'model' => App\Models\RefreshToken::class,

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

By 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.