我正在使用 Filament 創建一個表。我的 Livewire 類中有以下兩個函式。getTableRecordUrlUsing() 函式按預期作業。
getTableActions() 函式生成一個錯誤頁面,顯示“[Route: recipe.show] [URI: recipe/{id}] [Missing parameter: id] 缺少必需的引數。”
protected function getTableActions()
{
return [
Action::make('edit')
->url(fn (Recipe $r): string => route('recipe.show', ['id' => $r])),
];
}
protected function getTableRecordUrlUsing()
{
return function (Recipe $r) {
return route('recipe.show', ['id' => $r]);
};
}
一個功能有效。另一個沒有。我沒主意了。
uj5u.com熱心網友回復:
不要更改 filament 中的閉包引數名稱,嘗試將$r重命名為$record:
protected function getTableActions()
{
return [
Action::make('edit')
->url(fn (Recipe $record): string => route('recipe.show', ['id' => $record])),
];
}
...
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/537873.html
標籤:PHP拉维laravel 灯丝
上一篇:將鍵值對附加到現有陣列鍵
