ReferencePremium
CoullWorks Blog for Laravel contracts reference
Every contract you can bind, with its methods, plus the container tags and extension points.
Updated 16 November 2026Back to the package pageBuy
Bind your own class to a contract to change how the package behaves. For worked examples see Events and contracts.
Admin panel contracts#
PanelExtension#
What a module (comments, analytics, import, ai) hands the panel. Implementations live in the module's own Filament sub-namespace and are tagged in the container under Core's cwb.panel-extensions by class name.
- Interface:
src/Filament/Contracts/PanelExtension.php
Methods:
id(): string: Unique, for example 'comments'. */resources(): arraypages(): arraywidgets(): arraynavigation(): arraysettingsSections(): arraypostEditorSections(): arrayabilities(): array
Ai contracts#
AiProvider#
One AI vendor behind the module. A driver also implements the capability interfaces it really has (ResearchesWeb, WritesStructured, MakesImages); there are no stub methods for the others. Callers use only these contracts, so how a driver talks to its vendor can change without touching them.
- Interface:
src/Ai/Contracts/AiProvider.php
Methods:
code(): string: The provider code, for example anthropic. */models(): array: The models to offer, from config.checkCredential(#[\SensitiveParameter] string $apiKey): bool: Whether the vendor accepts the key. Never throws and never reveals the key. */
MakesImages#
Implemented by an AI driver that can generate pictures. image() takes an image request and returns an image result.
- Interface:
src/Ai/Contracts/MakesImages.php
Methods:
image(ImageRequest $request): ImageResult
ResearchesWeb#
Implemented by an AI driver that can research the web. research() takes a research request and returns a research result (sources and claims).
- Interface:
src/Ai/Contracts/ResearchesWeb.php
Methods:
research(ResearchRequest $request): ResearchResult
WritesStructured#
Implemented by an AI driver that can write structured output. generate() takes a generate request and returns a structured result.
- Interface:
src/Ai/Contracts/WritesStructured.php
Methods:
generate(GenerateRequest $request): StructuredResult
Api contracts#
Payload#
a readonly, framework-independent payload. The JSON:API resources put toArray() into attributes and meta() into meta; the Inertia front end builds its props from the same objects.
- Interface:
src/Api/Contracts/Payload.php
Methods:
toArray(): arraymeta(): array
Blocks contracts#
BlockType#
One block type. Owned by the Blocks module (Rulings 6); apps register their own through the registry.
- Interface:
src/Blocks/Contracts/BlockType.php
Methods:
key(): string: A namespaced key such as coullworks.figure. */currentVersion(): intgroup(): stringicon(): stringdataClass(): stringfromArray(array $data, int $v): BlockData: Upgrades the stored data to the current version in memory, then builds the typed data class.upgrade(array $data, int $from): array: Runs the upgraders from version $from up to the current version, in order, on the data in memory.normalise(array $data, ?Sanitiser $sanitiser = null): array: Fills defaults, drops unknown keys, casts types and passes rich text through the Sanitiser when one is given. Normalising twice gives the same result.rules(): array: Laravel validation rules relative to the block's data.checks(array $data): array: Checks a rule string cannot express. Keys are field paths relative to data.editor(): BlockEditorSpecrendererKey(): stringreferences(array $data): arrayplainText(array $data): stringchildrenField(): ?string: The field holding child blocks, when the type nests blocks. */upgraders(): array: Upgraders keyed by the version they upgrade from: 1 turns v1 data into v2 data.
ConsentChecker#
Tells the blocks whether the visitor has consented to an embed provider such as YouTube, Vimeo or Spotify.
- Interface:
src/Blocks/Contracts/ConsentChecker.php
Methods:
granted(string $provider): bool: Whether the visitor has consented to the provider (youtube, vimeo, spotify, ...). */
HasNotices#
Optional on a BlockType: things about its data that must not fail the save but that an editor should see, such as a reference to something the host no longer provides. Each notice becomes a Notice of the validation report.
- Interface:
src/Blocks/Contracts/HasNotices.php
Methods:
notices(array $data): array
ProductProvider#
Optional. A host binds it to enrich product cards. The package has no product table and no default provider.
- Interface:
src/Blocks/Contracts/ProductProvider.php
Methods:
resolve(array $refs, ?string $collectionKey = null): array
ProductRuleProvider#
Optional. A host that has a catalogue binds it to offer named product rules ("same category as the post", "best sellers") to a products block. The package has no catalogue, so it ships no rule and no condition tree: it hands the host the page being rendered and the display count, and takes product references back, which ProductProvider then turns into cards.
- Interface:
src/Blocks/Contracts/ProductRuleProvider.php
Methods:
rules(): arrayresolve(string $ruleKey, int $limit, ProductRuleContext $context): array
Comments contracts#
SpamVerifier#
The one contract this module owns. A host binds its own; the default binding passes unless a blog chooses the Turnstile or reCAPTCHA verifier the package ships.
- Interface:
src/Comments/Contracts/SpamVerifier.php
Methods:
check(SpamCheckRequest $request): SpamVerdict
Core contracts#
AuthorProvider#
Supplies author profiles for your application's users. profileFor() returns the profile for a user key, or nothing. search() finds profiles by a search term.
- Interface:
src/Core/Contracts/AuthorProvider.php
Methods:
profileFor(string $userKey): ?AuthorProfilesearch(string $term): iterable
BlogResolver#
Decides which blog a request belongs to, from the request itself. The default resolves by domain or path. Bind your own to resolve differently.
- Interface:
src/Core/Contracts/BlogResolver.php
Methods:
resolve(Request $request): ?Blog
ContentAccess#
The extension gate a host binds when it wants to restrict or allow the viewing of a post, a category or a listing. The default binding allows everyone. The contract can only narrow what is visible: a draft, scheduled, archived or inactive item stays hidden whatever it answers. allows and constrain must agree (Core\Testing\ContentAccessAgreement checks a host's rule).
- Interface:
src/Core/Contracts/ContentAccess.php
Methods:
allows(?Authenticatable $viewer, AccessSubject $subject): bool: Whether the viewer may see one post, one category or one kind of listing. /constrain(Builder/EloquentBuilder $query, ?Authenticatable $viewer, AccessKind $kind, string $table): void: Narrows a post or category query, so a listing stays filtered in SQL (pagination and counts stay right, no query per item).$tableis the table or alias the rows of this kind have in the query: a post query has the posts table (or its alias) in it, a category query is a sub query on the categories table.varies(): bool: True when the answer depends on the viewer, so a response built for a signed-in viewer must not be stored by a shared cache. /denied(Request $request, AccessSubject $subject): Response/RedirectResponse/JsonResponse/null: The host's own reply to a denied request (a redirect to its login, a teaser), or null for the default 404. /
ContentValidator#
Validates a list of blocks and returns them normalised, throwing InvalidContent when they are not valid. plainText() returns the plain text of a block list.
- Interface:
src/Core/Contracts/ContentValidator.php
Methods:
validate(array $blocks): arrayplainText(array $blocks): string
LicenceChecker#
Asks the licensing server whether a key is valid for a host and returns the answer. It throws a ConnectionException when the server cannot be reached.
- Interface:
src/Core/Contracts/LicenceChecker.php
Methods:
check(string $host, string $key): LicenceAnswer
PathPatterns#
Returns the URL path map (the patterns for index, post, category and so on) of one blog.
- Interface:
src/Core/Contracts/PathPatterns.php
Methods:
forBlog(Blog $blog): PathMap
PostExtra#
A typed per-page value a module adds to a post page or listing (reading time, comments count...). Holds per-page values only: extras are part of cached page data.
- Interface:
src/Core/Contracts/PostExtra.php
Methods:
type(): stringslot(): string: For example meta, after-content, sidebar, card-meta. /view(string $viewSet): ?string: The partial for the given view set (tailwind or bootstrap); null when the module ships none. /toArray(): array
PostExtraProvider#
Supplies extras to show in the front-end slots around a post. forPost() returns the extras for a post page and forListing() the extras for a listing.
- Interface:
src/Core/Contracts/PostExtraProvider.php
Methods:
forPost(PostPageContext $context): arrayforListing(ListingContext $context, Collection $posts): array
Sanitiser#
Cleans an HTML string for a sanitiser profile (the default profile is Content) and returns the safe HTML.
- Interface:
src/Core/Contracts/Sanitiser.php
Methods:
clean(string $html, SanitiserProfile $profile = SanitiserProfile::Content): string
SearchEngine#
Runs a search query and returns post translation ids in order with scores. Core applies visibility to the ids afterwards.
- Interface:
src/Core/Contracts/SearchEngine.php
Methods:
search(SearchQuery $query): SearchResults: Ordered post translation ids with scores; Core applies visibility to the ids afterwards. /
SeoBatchContributor#
Optional for a SeoContributor that reads data per post (a comment count): called once for a page of posts, before each post's document is built, so the contributor can read the whole page in one statement instead of one per post.
- Interface:
src/Core/Contracts/SeoBatchContributor.php
Methods:
prime(Blog $blog, string $locale, Collection $translations): void
SeoContributor#
Adds to the SEO data of a page. priority() orders contributors (lower runs first) and contribute() receives the SEO data and the page context and returns the changed data.
- Interface:
src/Core/Contracts/SeoContributor.php
Methods:
priority(): int: Lower runs first. /contribute(SeoData $seo, PageContext $context): SeoData
Urls#
The only way Core builds a URL. Every method takes the blog explicitly so no lazy relation load is hidden inside.
- Interface:
src/Core/Contracts/Urls.php
Methods:
path(Blog $blog, string $kind, array $values = []): string: Path of a page kind (leading slash, blog prefix applied).url(Blog $blog, string $kind, array $values = []): stringpost(Blog $blog, PostTranslation $translation): stringpostPath(Blog $blog, PostTranslation $translation): stringcategory(Blog $blog, CategoryTranslation $translation): stringcategoryPath(Blog $blog, CategoryTranslation $translation): stringtag(Blog $blog, TagTranslation $translation): stringtagPath(Blog $blog, TagTranslation $translation): stringauthor(Blog $blog, Author $author, string $locale): stringlisting(Blog $blog, string $locale, int $page = 1): stringsearch(Blog $blog, string $locale, ?string $term = null, int $page = 1): stringfeed(Blog $blog, string $locale, ?string $categorySlug = null): stringsitemap(Blog $blog, ?string $file = null): stringpreview(Blog $blog, Post $post, PostTranslation $translation): string: The post's URL plus a PreviewTokens token. /
Filament contracts#
PanelExtension#
What a module (comments, analytics, import, ai) hands the panel. Implementations live in the module's own Filament sub-namespace and are tagged in the container under Core's cwb.panel-extensions by class name.
- Interface:
src/Filament/Contracts/PanelExtension.php
Methods:
id(): string: Unique, for example 'comments'. */resources(): arraypages(): arraywidgets(): arraynavigation(): arraysettingsSections(): arraypostEditorSections(): arrayabilities(): array
PostEditorSection#
A section rendered inside the Post editor by another module and saved with the post's Save action.
- Interface:
src/Filament/Contracts/PostEditorSection.php
Methods:
key(): stringability(): stringschema(): arrayfill(PostTranslation $translation): arraysave(PostTranslation $translation, array $state): void
SettingsSection#
A section of the Settings page owned by another module. The page stores none of its values.
- Interface:
src/Filament/Contracts/SettingsSection.php
Methods:
key(): stringability(): stringschema(): arrayfill(): arraysave(array $state): void
Import contracts#
DnsResolver#
The DNS seam of the media rules: the addresses a host name resolves to.
- Interface:
src/Import/Contracts/DnsResolver.php
Methods:
resolve(string $host): array
ImportSource#
A place content is imported from. Apps register their own in the ImportSourceRegistry and the source runs through the same pipeline, import map, hash rule and redirects as the built-in ones.
- Interface:
src/Import/Contracts/ImportSource.php
Methods:
code(): string: The code used on the command line and in the registry. */describe(): array: What the source needs, for the command and the wizard.validate(ImportOptions $options): ValidationReport: The problems found before anything is read; an empty report means the source can be read. */records(string $entityType, ImportOptions $options): iterable: A lazy sequence of the records of one entity type (author, category, tag, post, comment, feed). Parents come before their children.oldAddresses(SourceRecord $record, ImportOptions $options): array: The old public addresses of a record, absolute (https://old.example.com/a/) or relative to the blog's host (/a/).paginationPatterns(ImportOptions $options): array: Old listing pagination paths as patterns (for example /page/{int}), absolute or relative to the blog's host.
Container tags#
| Name | What it is |
|---|---|
Container tag: cwb.panel-extensions | PanelExtension classes (Core PanelExtensions::TAG). |
Container tag: cwb.ai-providers | AiProvider classes (custom AI provider). |
Container tag: SeoContributors::TAG | SeoContributor classes (blocks, ai citations, comments count). |
Container tag: PostExtraProvider (cwb extras) | Post extras shown in front-end slots: Analytics, Comments, AI disclosure. |
Container tag: cwb.import-sources / ImportSourceRegistry | Register extra ImportSource classes. |
Panel extensions#
| Name | What it is |
|---|---|
Panel extension: ai | Registered only when ai.enabled. |
Panel extension: comments | Registered only when comments.enabled. |
Panel extension: analytics | Registered only when analytics.enabled. |
Panel extension: import | Registered only when import.enabled. |







