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