diff --git a/src/Fields/Variants.php b/src/Fields/Variants.php index 8b3da4bb..dbd4edc1 100644 --- a/src/Fields/Variants.php +++ b/src/Fields/Variants.php @@ -50,9 +50,13 @@ public function fields(Request $request): array BelongsToMany::make(__('Property Values'), 'propertyValues') ->withRelatableQuery(static function (Request $request, Builder $query, Variant $model): Builder { + $product = $model->relationLoaded('product') + ? $model->product + : $model->product()->make()->forceFill(['id' => $model->product_id]); + return $query->whereIn( $query->qualifyColumn('id'), - $model->product->propertyValues()->select('bazar_property_values.id') + $product->propertyValues()->select('bazar_property_values.id') ); }) ->with(['property'])