API Reference

Quick reference for the models, services, and helpers available in FrankenCMS.

Models

Post

php
use FrankenCms\Models\Post;

// Query scopes
Post::visibleOnFrontend()->get();

// Relationships
$post->author;          // User model
$post->terms;           // All taxonomy terms
$post->categories;      // Category terms only
$post->tags;            // Tag terms only
$post->parent;          // Parent post/page
$post->children;        // Child posts/pages

// Media (Spatie Media Library)
$post->getFirstMedia('featured');   // Featured image
$post->getFirstMedia('seo-og');     // OG image
$post->seoOgImage();                // OG image with fallbacks
$post->seoTwitterImage();           // Twitter image with fallbacks

// Meta
$post->getMeta('seo_title');
$post->setMeta('seo_title', 'Custom Title');

// Attributes
$post->template;        // Template name
$post->custom_fields;   // Custom field data
$post->isPublished();   // Check if published

Page

Page extends Post with a global scope that filters to pages only. It shares the same relationships and methods.

php
use FrankenCms\Models\Page;

Page::visibleOnFrontend()->get();

$page->template;            // Default: 'page-home'
$page->parent;              // Parent page
$page->children;            // Child pages
$page->ancestors();         // All ancestors (collection)
$page->getHierarchicalPath(); // e.g. '/about/team/leadership'

Taxonomy & Term

php
use FrankenCms\Models\Taxonomy;
use FrankenCms\Models\Term;

// Taxonomy
$taxonomy->terms;               // All terms in this taxonomy

// Term
$term->taxonomy;                // Parent taxonomy
$term->posts;                   // Posts with this term
$term->pages;                   // Pages with this term
$term->parent;                  // Parent term
$term->children;                // Child terms
Term::forTaxonomy('category');  // Scope by taxonomy name

Menu

php
use FrankenCms\Models\Menu;

$menu = Menu::findBySlug('main-nav');

$menu->menuItems;           // Top-level items
$menu->allMenuItems;        // All items including children
$menu->getCachedMenuItems(); // Hierarchical array (cached)
$menu->clearCache();         // Clear this menu's cache

Services

MenuService

php
use FrankenCms\Services\MenuService;

$menuService = app(MenuService::class);

$menu = $menuService->getMenu('main-nav');
$items = $menuService->getMenuItems('main-nav');
$flat = $menuService->getFlatMenuItems('main-nav');
$breadcrumb = $menuService->getBreadcrumb('main-nav', $currentUrl);
$menuService->clearAllMenuCaches();

SeoService

The SEO service provides getter methods that resolve values from the post, then fall back to global settings. These are used internally by the @seoHead directive.

php
use FrankenCms\Services\SeoService;

$seo = app(SeoService::class);

$seo->getTitle($post);
$seo->getDescription($post);
$seo->getCanonicalUrl($post);
$seo->getRobotsContent($post);
$seo->getOgTitle($post);
$seo->getOgDescription($post);
$seo->getOgImage($post);
$seo->getOgType($post);

AiService

php
use FrankenCms\Services\AiService;

$ai = app(AiService::class);

$result = $ai->generate('generate_seo_title', [
    'title' => 'Post Title',
    'content' => 'Post body...',
]);

$ai->testConnection(); // Verify provider API key works

Helper Functions

php
// Get a rendered template field value
$value = frankenField('hero.title');

// Get a setting value (group.property)
$name = setting('general.title');
$perPage = setting('reading.posts_per_page', 10);

// Generate favicon HTML tags
$html = favicon_tags();

Configuration

Available keys in config/franken-cms.php:

Key Description
navigation_group_name Admin panel navigation group name
theme_folder Theme directory within resources/views
models.user User model class
media_disk_name Storage disk for media
menu_cache Menu cache TTL in seconds
cache_parsed_fields Cache parsed template fields
breadcrumbs.enabled Enable breadcrumbs globally
breadcrumbs.home_text Home link text in breadcrumbs
user_bio.image_shape Profile image shape: circle or square

Next Steps