概要
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());
}
}