0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Filament 2.x】ダッシュボードのテーブル名を書き換える

Posted at

概要

Resourceクラスであれば、$modelLabelプロパティで書き換えられますが、ダッシュボードのテーブル名の書き換え方が分からなかった。

app/Filament/Resources/StoreResource.php
protected static ?string $modelLabel = '店舗';

解決法

headingプロパティで書き換える。

app/Filament/Widgets/Stores.php
class Stores extends BaseWidget
{
    protected static ?string $heading = '店舗';

備考

継承元のBaseWidgetクラスに$headingがnullならクラス名そのまま使うみたいな処理が書いてあるが
これドキュメントのどこに書いてあるんだろう?誰か教えてクレメンス

class TableWidget extends Widget implements Tables\Contracts\HasTable
{
    use Tables\Concerns\InteractsWithTable;

    protected static string $view = 'filament::widgets.table-widget';

    protected static ?string $heading = null;

    protected function getTableHeading(): string | Htmlable | Closure | null
    {
        return static::$heading ?? (string) Str::of(class_basename(static::class))
            ->beforeLast('Widget')
            ->kebab()
            ->replace('-', ' ')
            ->title();
    }

    protected function paginateTableQuery(Builder $query): Paginator
    {
        return $query->simplePaginate($this->getTableRecordsPerPage() == -1 ? $query->count() : $this->getTableRecordsPerPage());
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?