Skip to content
Shamar

Your first resource

A resource is the unit of work in a Shamar panel. One class stands for one kind of record — products, companies, tickets — and the panel builds four screens from it: a list, a create form, an edit form, and a read-only show page. You do not add four routes or four Edge templates. You describe the form and the table, point the class at a model, and register it on a panel.

This guide assumes the panel is already installed and you can open it in a browser. If /admin does not exist yet, do Installation first. If the words “resource” and “panel” are still new, Introduction is the map. What follows is the smallest class that produces a real list and a real form.

A resource list — searchable columns, filters, grouping, bulk actions, and sticky headings are provided by the Adonis host.
import { Resource, TextInput, TextColumn, type FormBuilder, type TableBuilder } from '@shamar/core'
import Product from '#models/product'
export default class ProductResource extends Resource {
static model = Product
static slug = 'products'
static label = 'Products'
static navigationGroup = 'Catalog'
static form(form: FormBuilder) {
return form.schema([
TextInput.make('name').required(),
TextInput.make('sku').required(),
TextInput.make('price').numeric().required(),
])
}
static table(table: TableBuilder) {
return table.schema([
TextColumn.make('name').searchable().sortable(),
TextColumn.make('sku').searchable(),
TextColumn.make('price').sortable(),
])
}
}

Register the resource on a panel in config/shamar.ts, then open /admin/products.

The form schema drives create/edit — see the [Forms reference](/docs/reference/forms/) for every field type.
  • Use Section, Tabs, and Grid inside form() for layout (Filament-style schema nodes).
  • Mark columns .searchable() / .sortable() for list chrome.
  • Prefer the Forms reference over raw HTML.