mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
fix(filament): fixed pivot action logs (#939)
This commit is contained in:
@@ -25,10 +25,9 @@ trait HasPivotActionLogs
|
||||
if ($relation instanceof BelongsToMany) {
|
||||
$pivotClass = $relation->getPivotClass();
|
||||
|
||||
// TODO: This needs to be updated/fixed for member/group artist relation
|
||||
$pivot = $pivotClass::query()
|
||||
->where($ownerRecord->getKeyName(), $ownerRecord->getKey())
|
||||
->where($record->getKeyName(), $record->getKey())
|
||||
->where($relation->getForeignPivotKeyName(), $ownerRecord->getKey())
|
||||
->where($relation->getRelatedPivotKeyName(), $record->getKey())
|
||||
->first();
|
||||
|
||||
ActionLog::modelPivot(
|
||||
@@ -36,7 +35,7 @@ trait HasPivotActionLogs
|
||||
$ownerRecord,
|
||||
$record,
|
||||
$pivot ?? $record,
|
||||
$action
|
||||
$action,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ use Filament\Facades\Filament;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
@@ -302,7 +303,7 @@ class ActionLog extends Model implements Nameable
|
||||
ActionLog::ATTRIBUTE_TARGET_TYPE => Relation::getMorphAlias($parent->getMorphClass()),
|
||||
ActionLog::ATTRIBUTE_TARGET_ID => $parent->getKey(),
|
||||
ActionLog::ATTRIBUTE_MODEL_TYPE => Relation::getMorphAlias($pivot->getMorphClass()),
|
||||
ActionLog::ATTRIBUTE_MODEL_ID => $pivot->getKey(),
|
||||
ActionLog::ATTRIBUTE_MODEL_ID => $pivot instanceof Pivot ? null : $pivot->getKey(),
|
||||
ActionLog::ATTRIBUTE_FIELDS => $data ? static::getFields($data) : static::getFields($pivot->getAttributes(), $pivot),
|
||||
ActionLog::ATTRIBUTE_STATUS => ActionLogStatus::FINISHED->value,
|
||||
ActionLog::ATTRIBUTE_FINISHED_AT => Date::now(),
|
||||
|
||||
Reference in New Issue
Block a user