mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
fix: Missing record key
This commit is contained in:
@@ -474,8 +474,8 @@ class Action extends ViewComponent implements Arrayable
|
||||
|| (! $record instanceof Model)
|
||||
|| blank($table->getModel())
|
||||
|| ($record::class === $table->getModel())
|
||||
)) {
|
||||
$context['recordKey'] = $this->resolveRecordKey($record);
|
||||
) && filled($recordKey = $this->resolveRecordKey($record))) {
|
||||
$context['recordKey'] = $recordKey;
|
||||
}
|
||||
|
||||
if ($table && $this->isBulk()) {
|
||||
|
||||
@@ -155,13 +155,19 @@ trait InteractsWithRecord
|
||||
/**
|
||||
* @param Model | array<string, mixed> $record
|
||||
*/
|
||||
public function resolveRecordKey(Model | array $record): string
|
||||
public function resolveRecordKey(Model | array $record): ?string
|
||||
{
|
||||
if (is_array($record)) {
|
||||
return $record[ArrayRecord::getKeyName()] ?? throw new LogicException('Record arrays must have a unique [' . ArrayRecord::getKeyName() . '] entry for identification.');
|
||||
return strval($record[ArrayRecord::getKeyName()] ?? throw new LogicException('Record arrays must have a unique [' . ArrayRecord::getKeyName() . '] entry for identification.'));
|
||||
}
|
||||
|
||||
return $record->getKey();
|
||||
$key = $record->getKey();
|
||||
|
||||
if (blank($key)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return strval($key);
|
||||
}
|
||||
|
||||
public function getCustomRecordTitle(?Model $record = null): ?string
|
||||
|
||||
Reference in New Issue
Block a user