Skip to content

Categories

Kompass includes a built-in category management system that lets you group your posts. Each category can be customized with a unique name, slug, color, and icon.

Categories overview

Overview

Categories provide a way to taxonomize your content. They are managed via a dedicated interface in the admin dashboard, where you can:

  • Create, edit, and delete categories.
  • Assign colors for visual differentiation (e.g., in badges).
  • Choose icons from the built-in Tabler Icons set.
  • Define descriptions for better SEO or frontend display.
  • Set a custom sort order.

Managing Categories

Navigate to Admin > Categories to view the category table, which lists each category with its color badge and icon.

Creating a Category

Click New category to open the editor:

Category editor

FieldRequiredDescription
NameYesThe display name of the category.
SlugNoURL-friendly version of the name (auto-generated from the name if empty).
DescriptionNoA short summary of the category.
ColorNoA named theme color (default: primary).
IconNoA Tabler icon name.
OrderNoNumeric value to control the display sequence (default: 0).

Color

Color is picked from a fixed set of named theme colorsprimary, secondary, accent, info, success, warning, error, and neutral. The chosen name is stored as-is in the color column and used to build the badge class (e.g. badge-secondary) on the frontend.

Icon Picker

The category editor includes an interactive Icon Picker. Search for an icon by name and click it; Kompass stores the full tabler- name (e.g. tabler-accessible-filled).

Using Categories in Code

Categories are standard Eloquent models. You can access them via the Secondnetwork\Kompass\Models\Category class.

Relationships

Each post belongs to one category (posts.category_id), and a category has many posts:

php
// A post's category (belongsTo)
$post = Post::find(1);
$category = $post->category;

echo $category->name;
echo $category->icon;   // e.g. tabler-accessible-filled
echo $category->color;  // e.g. secondary

// All posts in a category (hasMany)
$category = Category::where('slug', 'naff')->first();
$posts = $category->posts;

Frontend Badges

Use the category's color and icon to render a badge in your Blade templates:

blade
@if ($post->category)
    <span class="badge badge-{{ $post->category->color }} flex items-center gap-1">
        @if ($post->category->icon)
            @svg($post->category->icon, 'w-4 h-4')
        @endif
        {{ $post->category->name }}
    </span>
@endif

Released under the MIT License.