Skip to content

Commit 5140061

Browse files
committed
Add null checks for record arguments in KanbanBoard actions; prevent errors when record is not set
1 parent f8a3804 commit 5140061

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Livewire/KanbanBoard.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,24 @@ public function editAction(): ?Action
216216

217217
$action = Action::make('edit')
218218
->model(function (Action $action, array $arguments) {
219-
return $this->adapter->getModelById($arguments['record'])::class;
219+
return isset($arguments['record']) ? $this->adapter->getModelById($arguments['record'])::class : null;
220220
})
221221
->record(function (array $arguments) {
222-
return $this->adapter->getModelById($arguments['record']);
222+
return isset($arguments['record']) ? $this->adapter->getModelById($arguments['record']) : null;
223223
})
224224
->fillForm(function (Action $action, array $arguments) {
225+
if (!isset($arguments['record'])) {
226+
return [];
227+
}
225228
$record = $this->adapter->getModelById($arguments['record']);
226229

227230
return $record->toArray();
228231
})
229232
->action(function (Action $action, array $arguments) {
233+
if (!isset($arguments['record'])) {
234+
return;
235+
}
236+
230237
$record = $this->adapter->getModelById($arguments['record']);
231238
$record->fill($action->getData());
232239
$record->save();

0 commit comments

Comments
 (0)