Skip to content

Commit

Permalink
Fix migration
Browse files Browse the repository at this point in the history
  • Loading branch information
pa-cholek committed Jul 26, 2024
1 parent 2a6f7a7 commit 0598f11
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions app/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,25 @@ public function schemas(): HasMany
->with(['options', 'metadata', 'metadataPrivate', 'options.metadata', 'options.metadataPrivate']);
}

/**
* @deprecated
*/
public function oldRequiredSchemas(): BelongsToMany
{
return $this->oldSchemas()->where('required', true);
}

/**
* @deprecated
*/
public function oldSchemas(): BelongsToMany
{
return $this
->belongsToMany(Schema::class, 'product_schemas')
->with(['options', 'metadata', 'metadataPrivate', 'options.metadata', 'options.metadataPrivate'])
->orderByPivot('order');
}

public function scopePublic(Builder $query): Builder
{
return $query->where('public', true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function up(): void
// $items = Item::all();
// $items->each(fn ($item) => $availabilityService->calculateAvailabilityOnAllItemRelations($item));

$products = Product::doesntHave('schemas')->get();
$products = Product::doesntHave('oldSchemas')->get();
$products->each(function (Product $product): void {
$product->update(['available' => true]);
});
Expand Down

0 comments on commit 0598f11

Please sign in to comment.