Skip to content

feat(board): name the cards after the model - #174

Open
grafst wants to merge 2 commits into
relaticle:4.xfrom
blemli:feat/model-based-card-labels
Open

feat(board): name the cards after the model#174
grafst wants to merge 2 commits into
relaticle:4.xfrom
blemli:feat/model-based-card-labels

Conversation

@grafst

@grafst grafst commented Aug 27, 2026

Copy link
Copy Markdown

Why

A board always calls its cards records:

No records in this column

But the board knows its model, and inside a panel that model usually has a resource with proper — and translated — labels. An audiobook board can just as well say:

No audiobooks in this column

What

Board gains cardLabel() and pluralCardLabel(), and resolves the defaults in this order:

  1. an explicit cardLabel() / pluralCardLabel() (string or closure),
  2. the resource of the board page (BoardResourcePage),
  3. the resource registered for the model in the current panel (Filament::getModelResource()),
  4. the model name itself (Str::title(Str::snake(class_basename($model), ' '))).

A board without a query — or outside a panel, where nothing can be resolved — keeps the existing flowforge::flowforge.card_label wording, so standalone usage is unchanged.

->cardLabel('Ticket')
->pluralCardLabel('Tickets')

Notes

  • Everything lives in a new HasCardLabels concern; Board::getViewData() just calls the getters, so the labels reach both the Blade views and the JS config as before.
  • filament/filament stays optional: the panel lookup is skipped when the facade is missing or no panel is current.
  • Tests: tests/Feature/CardLabelTest.php covers all four resolution steps plus the rendered empty column. Full suite green (167 passed), PHPStan reports no new errors, Pint clean.
  • Docs: the two methods are added to the API reference.

Based on #173 — the German lang fix it contains is the first commit here and disappears from this diff once that one lands.

grafst added 2 commits August 27, 2026 15:04
… hint

The empty-column view lowercases the plural card label before it is
interpolated, which reads naturally in English but breaks German, where
nouns are always capitalised: the board showed "Keine datensätze in
dieser Spalte".

Use Laravel's capitalising placeholder in the German line so the label
comes back capitalised. No other locale is affected.
The empty-column hint and the card counters always said "records",
whatever the board actually holds. Boards know their model, and in a
panel the model usually has a resource with proper (and translated)
labels, so use those: an audiobook board now reads "No audiobooks in
this column" instead of "No records in this column".

Resolution order: an explicit cardLabel()/pluralCardLabel(), then the
resource of the board page, then the resource registered for the model
in the current panel, then the model name itself. Boards without a
query keep the previous translated wording.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant