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クラスから生成されるテーブルではなく、テーブルビルダーを使ってテーブルを生成した際
groupByで集計テーブルを作った時に主キーが無いのでエラーが出る。

例えば、勤怠テーブルを集計して誰が指定月に何回出勤した などの表を作りたい際

getTableRecordKey(): Return value must be of type string, null returned

オーバーライドして空文字を返す。

class MonthlyWorkDailyReportTable extends Component implements Tables\Contracts\HasTable
{
    use Tables\Concerns\InteractsWithTable;
...

    public function getTableRecordKey(Model $record): string
    {
        return '';
    }
}
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?