Register originals and variants on your own models
ImplementRegistersApplicationMedia on the Eloquent model that owns the file.
The model publishes the logical image and the ready variants of that revision.
This works with your own uploader or native Filament FileUpload. Store the
paths, actual MIME types and byte lengths when your upload or conversion job
finishes so the registration can read them without accessing storage.
cover_variants is an array-cast attribute containing only the
ready variants for cover_revision. Keep the slot key stable across replacements.
Use immutable object paths and a new revision when replacing the original. A
conversion job must publish its metadata only if its source revision is still
current. The five variants can share a flat prefix with every other post. Studio
indexes the cover slot as one file and uses only the two configured display roles.
Register the source with the allowed storage locations and a model access scope:
(Builder $query, ?TenantIdentity $tenant, Principal $principal) and returning the scoped Eloquent builder.
Apply the same owner and tenant restrictions that govern the original file.
For tenant-specific disks, a service provider may register a prefix callback
receiving the resolved tenant. Keep scoped model registration stateless and use
already-loaded attributes. If a gallery has many photos per post, register the
individual photo model. Each owner can register up to 32 slots with up to 16
variants each. Owners use the same database connection as the catalog.
Backfill one bounded batch at a time:
ApplicationCatalog::syncModel($principal, 'posts', (string) $postId) after
commit. It reloads the authoritative model and removes projections for slots
the model no longer declares. For a hard delete, call
forgetDeletedModel($principal, 'posts', (string) $postId) after commit to
remove the catalog records. Removed or unauthorized owners are immediately
hidden and delivery checks the current slot and revision. The owning uploader
continues to control storage and deletion.
When switching from an existing raw disk source, remove its
allow_unregistered flag to hide its path-based entries. Keep raw opt-in sources
disjoint from prefixes registered by a model. The catalog treats two explicitly
configured sources as different access scopes.
Spatie models and collections
Spatie sources require an explicit Eloquent scope. The callback receives the query, the current tenant (ornull in a non-tenanted application), and the principal.
The example below is for a non-tenanted application exposing its Post media to
users granted the source permission:
ApplicationCatalog::indexSpatie() from your trusted synchronization process.
Automatic global discovery is not implied by enabling the catalog.