fix: Missing record key

This commit is contained in:
Dan Harrin
2025-09-15 11:04:24 +01:00
parent 959a87ea32
commit f231ec1b7c
2 changed files with 11 additions and 5 deletions
+2 -2
View File
@@ -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