storageAction($fields); $storageResults = $action->handle(); $storageResults->toLog(); $model = $action->then($storageResults); $actionResult = $storageResults->toActionResult(); if ($actionResult->hasFailed()) { $this->failedLog($actionResult->getMessage()); return; } $livewire = $this->getLivewire(); if ($livewire instanceof BaseRelationManager) { /** @var BelongsToMany */ $relation = $livewire->getRelationship(); $pivotClass = $relation->getPivotClass(); $pivot = $pivotClass::query() ->where($livewire->getOwnerRecord()->getKeyName(), $livewire->getOwnerRecord()->getKey()) ->where($model->getKeyName(), $model->getKey()) ->first(); $this->updateLog($model, $pivot); } } }