# `PhoenixFilament.Resource`
[🔗](https://github.com/franciscpd/phoenix-filament/blob/main/lib/phoenix_filament/resource.ex#L1)

Declares an admin resource backed by an Ecto schema.

## Usage

    defmodule MyApp.Admin.PostResource do
      use PhoenixFilament.Resource,
        schema: MyApp.Blog.Post,
        repo: MyApp.Repo
    end

## Options

* `:schema` (`t:atom/0`) - Required. The Ecto schema module

* `:repo` (`t:atom/0`) - Required. The Ecto repo module

* `:label` (`t:String.t/0`) - Human-readable resource name (auto-derived from schema if omitted)

* `:plural_label` (`t:String.t/0`) - Plural form of label

* `:icon` (`t:String.t/0`) - Icon name for panel navigation

* `:create_changeset` - Changeset function as `{Module, :function_name}` tuple for create. Called as Module.function_name(struct, params). Default: `{schema, :changeset}` The default value is `nil`.

* `:update_changeset` - Changeset function as `{Module, :function_name}` tuple for update. Called as Module.function_name(record, params). Default: `{schema, :changeset}` The default value is `nil`.

# `__resource__`

```elixir
@callback __resource__(:schema) :: module()
@callback __resource__(:repo) :: module()
@callback __resource__(:opts) :: keyword()
@callback __resource__(:form_fields) :: [PhoenixFilament.Field.t()]
@callback __resource__(:form_schema) :: [
  PhoenixFilament.Field.t()
  | PhoenixFilament.Form.Section.t()
  | PhoenixFilament.Form.Columns.t()
]
@callback __resource__(:table_columns) :: [PhoenixFilament.Column.t()]
@callback __resource__(:table_actions) :: [PhoenixFilament.Table.Action.t()]
@callback __resource__(:table_filters) :: [PhoenixFilament.Table.Filter.t()]
```

Callback to retrieve resource metadata.

Valid keys: [:schema, :repo, :opts, :form_fields, :form_schema, :table_columns, :table_actions, :table_filters]

---

*Consult [api-reference.md](api-reference.md) for complete listing*
