GoFilament
You're reading the docs for v1.35.0, an older release. Go to v1.40.1 (latest).

Docs v1.35.0 Reference

Resource System (Resource[T] & BaseResource[T])

Resources map a data model to full administrative CRUD capabilities.

Resource Declaration & Model Binding#

package resources

import (
    "github.com/golaravel/gofilament/pkg/filament"
    "github.com/golaravel/gofilament/pkg/forms"
    "github.com/golaravel/gofilament/pkg/tables"
)

type Product struct {
    ID          string    `json:"id"`
    Title       string    `json:"title"`
    Price       float64   `json:"price"`
    Status      string    `json:"status"`
    Stock       int       `json:"stock"`
    DeletedAt   *time.Time `json:"deleted_at"`
}

func NewProductResource() *filament.BaseResource[*Product] {
    res := filament.NewResource[*Product]("products")

    res.ModelName("Product").
        PluralModelName("Products").
        NavigationGroup("Catalog").
        NavigationIcon(`<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"/></svg>`).
        RecordID(func(p *Product) string {
            return p.ID
        })

    return res
}

Lifecycle Handlers#

Attach data operations cleanly:

res.
    OnList(func(ctx *filament.Context, search, sortCol, sortDir string, page, perPage int, filters map[string]string) ([]*Product, int, error) {
        // Query Ent ORM or DB
        return products, totalCount, nil
    }).
    OnFind(func(ctx *filament.Context, id string) (*Product, error) {
        // Find single record
        return product, nil
    }).
    OnCreate(func(ctx *filament.Context, data map[string]any) error {
        // Insert record
        return nil
    }).
    OnUpdate(func(ctx *filament.Context, id string, data map[string]any) error {
        // Update record
        return nil
    }).
    OnDelete(func(ctx *filament.Context, id string) error {
        // Delete record
        return nil
    }).
    OnDeleteBulk(func(ctx *filament.Context, ids []string) error {
        // Bulk delete records
        return nil
    })

Inline Cell Editing & Row Reordering#

res.
    OnCellUpdate(func(ctx *filament.Context, id, column string, value any) error {
        // Handles instant cell updates from ToggleColumn, SelectColumn, or TextInputColumn
        return updateProductField(id, column, value)
    }).
    OnReorder(func(ctx *filament.Context, orderedIDs []string) error {
        // Handles drag-and-drop table row reordering
        return updateProductSortOrder(orderedIDs)
    })

Soft Deletes & Trash Recovery Bin#

Enable soft deletes with a single builder call:

res.
    SoftDeletes(true).
    SoftDeleteColumn("deleted_at").
    IsTrashed(func(p *Product) bool {
        return p.DeletedAt != nil
    }).
    OnRestore(func(ctx *filament.Context, id string) error {
        return restoreProduct(id)
    }).
    OnForceDelete(func(ctx *filament.Context, id string) error {
        return permanentlyDeleteProduct(id)
    }).
    OnRestoreBulk(func(ctx *filament.Context, ids []string) error {
        return restoreProductsBulk(ids)
    }).
    OnForceDeleteBulk(func(ctx *filament.Context, ids []string) error {
        return permanentlyDeleteProductsBulk(ids)
    })
  • When active, resource tables automatically inject tables.TrashedFilter().
  • Active records display Edit and Delete actions.
  • Trashed records display a [Trashed] badge, strike-through styling, and swap actions to Restore (⟲) and Force Delete (🗑).

Authorization Policies & Gates#

res.
    CanViewAny(func(ctx *filament.Context) bool {
        return ctx.UserHasRole("manager", "admin")
    }).
    CanCreate(func(ctx *filament.Context) bool {
        return ctx.UserCan("products.create")
    }).
    CanEdit(func(ctx *filament.Context, record *Product) bool {
        return ctx.UserCan("products.edit")
    }).
    CanDelete(func(ctx *filament.Context, record *Product) bool {
        return ctx.UserHasRole("admin")
    }).
    CanRestore(func(ctx *filament.Context, id string) bool {
        return ctx.UserHasRole("admin")
    }).
    CanForceDelete(func(ctx *filament.Context, id string) bool {
        return ctx.UserHasRole("super-admin")
    })

Dynamic Resource Status Tabs#

Group lists by workflow states with live counter badges:

res.
    EnableTabs(true).
    Tabs(
        filament.NewResourceTab("all", "All Products").
            Badge(func(ctx *filament.Context) string { return "150" }),
        filament.NewResourceTab("in_stock", "In Stock").
            Badge(func(ctx *filament.Context) string { return "128" }).
            Query(func(filters map[string]string) {
                filters["status"] = "in_stock"
            }),
        filament.NewResourceTab("out_of_stock", "Low / Out of Stock").
            BadgeColor("danger").
            Badge(func(ctx *filament.Context) string { return "22" }).
            Query(func(filters map[string]string) {
                filters["status"] = "out_of_stock"
            }),
    )

Pagination & Infinite Scroll#

res.
    // Classic pagination
    Pagination(25).
    PerPageOptions(10, 25, 50, 100).
    // Or infinite scroll:
    // InfiniteScroll(30).
    // Mobile pagination display:
    // filament.PaginationPositionFab (circular floating button modal)
    // filament.PaginationPositionTop (compact top bar)
    MobilePaginationPosition(filament.PaginationPositionFab)

Column Controls#

Configure user column toggling, selectable visibility, and default columns:

res.
    DefaultColumns("id", "title", "price", "status").
    SelectableColumns("id", "title", "sku", "price", "stock", "status", "created_at").
    AdvancedSearchableColumns("title", "sku", "id")

Generated from DOCUMENTATION.md at v1.35.0 · released Nov 17, 2026