goldnead/statamic-affiliates
Statamic Affiliates is an addon for Statamic CMS that brings affiliate and referral tracking to your site. Manage affiliates, generate referral links, and attribute visits or conversions through a simple control-panel workflow in your Laravel-powered Statamic projects.
This addon is a Statamic Control Panel addon whose visible surface area is its settings screen. The v0.2.1 release only changes where that screen appears in the CP, so a new developer's first hour is mostly orientation.
composer require the addon, then php artisan config:clear && php artisan view:clear (Statamic will discover the addon via its service provider; no migration or new config key exists as of v0.2.1, so there is nothing to publish just to get running).src/ for the settings class and resources/views/ for the CP screen. The nav entry is the anchor for everything else.Prerequisite worth pinning in your README: statamic-brand-context ^1.16 to get the nested layout. The addon still works below that — the method is simply ignored.
Read settings through the addon's settings class, never by scraping the CP screen. The nav relocation in v0.2.1 is purely presentational; values and keys are unchanged, so any code reading settings keeps working across the upgrade.
If you are building a sibling addon, implement settingsNavParent(): array yourself. It returns a [section, name] tuple pointing at your own CP navigation entry. That is the sanctioned way to get your settings rendered as a sub-item of your nav rather than dumped into the shared Addon-Suite page. Keep the tuple in a constant or a single method so the nav registration and the settings declaration can't drift apart.
Never hardcode the settings URL. The path differs between brand-context versions (nested under your nav vs. under Settings → Addon-Suite) and will differ again if the suite page is renamed. Generate links with cp_route(...) / the named route, and if you must link from a Blade view, resolve it at render time.
Branch on capability, not on a version string, where you can. If your own code needs to behave differently depending on where settings live, prefer a method_exists()-style check or Composer\InstalledVersions::satisfies() over parsing statamic-brand-context versions by hand. The addon itself already degrades gracefully, so mirror that politeness.
Test both layouts. A feature test that asserts the settings screen is reachable should assert on route name / response, not on a literal path fragment like /cp/settings/addon-suite/..., or it will break for half your matrix.
Upgrade workflow: bump the brand-context constraint, run the test suite, then click through the CP once. There is no migration step, so a failed upgrade is almost always a stale cache or a nav-tuple mismatch rather than data.
settingsNavParent() returns a section/name that doesn't match a registered nav entry (typo, renamed nav, addon nav disabled by permission), you don't get an error — you get the shared Addon-Suite page. Treat "settings ended up in the wrong place" as a nav-registration bug, not a settings bug.php artisan config:clear && php artisan view:clear. With no migration and no new config key, a "broken" upgrade is nearly always cached nav/config.settingsNavParent().settingsNavParent() is the extension point. It exists precisely so you don't monkey-patch nav registration or reach into brand-context internals. If you find yourself filtering nav items in a listener to reposition settings, you're working against the design.How can I help you explore Laravel packages today?