Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
public function up(): void
{
Schema::create('catalogue_products', function (Blueprint $table) {
Schema::create('pim_products', function (Blueprint $table) {
$table->id();
$table->string('code')->nullable();
$table->string('barcode')->nullable();
Expand All @@ -26,6 +26,6 @@ public function up(): void

public function down(): void
{
Schema::dropIfExists('catalogue_products');
Schema::dropIfExists('pim_products');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
public function up(): void
{
Schema::create('catalogue_categories', function (Blueprint $table) {
Schema::create('pim_categories', function (Blueprint $table) {
$table->id();
$table->foreignId('site_id')
->constrained()
Expand All @@ -31,6 +31,6 @@ public function up(): void

public function down(): void
{
Schema::dropIfExists('catalogue_categories');
Schema::dropIfExists('pim_categories');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
{
public function up(): void
{
Schema::table('catalogue_products', function (Blueprint $table) {
Schema::table('pim_products', function (Blueprint $table) {
$table->foreignId('category_id')
->nullable()
->after('name')
->constrained('catalogue_categories')
->constrained('pim_categories')
->nullOnDelete()
->cascadeOnUpdate();
});
}

public function down(): void
{
Schema::table('catalogue_products', function (Blueprint $table) {
Schema::table('pim_products', function (Blueprint $table) {
$table->dropForeign(['category_id']);
$table->dropColumn('category_id');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
public function up(): void
{
Schema::table('catalogue_products', function (Blueprint $table) {
Schema::table('pim_products', function (Blueprint $table) {
$table->foreignId('product_type_id')
->nullable()
->after('category_id')
Expand All @@ -20,7 +20,7 @@ public function up(): void

public function down(): void
{
Schema::table('catalogue_products', function (Blueprint $table) {
Schema::table('pim_products', function (Blueprint $table) {
$table->dropForeign(['product_type_id']);
$table->dropColumn('product_type_id');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
public function up(): void
{
Schema::create('catalogue_product_data', function (Blueprint $table) {
Schema::create('pim_product_data', function (Blueprint $table) {
$table->id();
$table->foreignId('product_id');

Expand All @@ -32,6 +32,6 @@ public function up(): void

public function down(): void
{
Schema::dropIfExists('catalogue_product_data');
Schema::dropIfExists('pim_product_data');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
public function up(): void
{
Schema::table('catalogue_products', function (Blueprint $table) {
Schema::table('pim_products', function (Blueprint $table) {
$table->string('origin_country_id', 2)->nullable();
$table->foreign('origin_country_id')
->references('id')
Expand All @@ -24,7 +24,7 @@ public function up(): void

public function down(): void
{
Schema::table('catalogue_products', function (Blueprint $table) {
Schema::table('pim_products', function (Blueprint $table) {
$table->dropForeign(['origin_country_id']);
$table->dropColumn([
'origin_country_id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
*/
public function up(): void
{
Schema::create('catalogue_product_prices', function (Blueprint $table) {
Schema::create('pim_product_prices', function (Blueprint $table) {
$table->id();
$table->foreignId('product_id')
->constrained('catalogue_products')
->constrained('pim_products')
->cascadeOnUpdate()
->cascadeOnDelete();
$table->foreignId('price_list_id')
Expand All @@ -35,6 +35,6 @@ public function up(): void
*/
public function down(): void
{
Schema::dropIfExists('catalogue_product_prices');
Schema::dropIfExists('pim_product_prices');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
*/
public function up(): void
{
Schema::table('catalogue_product_data', function (Blueprint $table) {
Schema::table('pim_product_data', function (Blueprint $table) {
$table->foreignId('category_id')->nullable()->after('product_id')
->constrained('catalogue_categories')
->constrained('pim_categories')
->cascadeOnUpdate()
->nullOnDelete();
});
Schema::table('catalogue_products', function (Blueprint $table) {
Schema::table('pim_products', function (Blueprint $table) {
$table->dropConstrainedForeignId('category_id');
});
}
Expand All @@ -27,13 +27,13 @@ public function up(): void
*/
public function down(): void
{
Schema::table('catalogue_products', function (Blueprint $table) {
Schema::table('pim_products', function (Blueprint $table) {
$table->foreignId('category_id')->nullable()->after('name')
->constrained('catalogue_categories')
->constrained('pim_categories')
->cascadeOnUpdate()
->nullOnDelete();
});
Schema::table('catalogue_product_data', function (Blueprint $table) {
Schema::table('pim_product_data', function (Blueprint $table) {
$table->dropConstrainedForeignId('category_id');
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
*/
public function up(): void
{
Schema::create('catalogue_product_has_property_value', function (Blueprint $table) {
$table->foreignId('product_id')->constrained('catalogue_products')->onDelete('cascade')->onUpdate('cascade');
Schema::create('pim_product_has_property_value', function (Blueprint $table) {
$table->foreignId('product_id')->constrained('pim_products')->onDelete('cascade')->onUpdate('cascade');
$table->foreignId('property_value_id')->constrained('pim_property_value')->onDelete('cascade')->onUpdate('cascade');
$table->timestamps();
$table->unique(['product_id', 'property_value_id'], 'product_property_value_unique');
Expand All @@ -24,6 +24,6 @@ public function up(): void
*/
public function down(): void
{
Schema::dropIfExists('catalogue_product_has_property_value');
Schema::dropIfExists('pim_product_has_property_value');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function up(): void
{
Schema::create('pim_group_has_product', function (Blueprint $table) {
$table->foreignId('product_id')
->constrained('catalogue_products', 'id')
->constrained('pim_products', 'id')
->cascadeOnUpdate()
->cascadeOnDelete();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
{
public function up(): void
{
Schema::table('catalogue_products', function (Blueprint $table) {
Schema::table('pim_products', function (Blueprint $table) {
$table->foreignId('tariff_code_id')->nullable()->after('origin_country_id')->constrained('world_tariff_codes')->cascadeOnUpdate()->cascadeOnDelete();
});
}

public function down(): void
{
Schema::table('catalogue_products', function (Blueprint $table) {
Schema::table('pim_products', function (Blueprint $table) {
$table->dropForeign(['tariff_code_id']);
$table->dropColumn('tariff_code_id');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
*/
public function up(): void
{
Schema::create('catalogue_product_has_custom_prop_value', function (Blueprint $table) {
Schema::create('pim_product_has_custom_prop_value', function (Blueprint $table) {
$table->id();
$table->foreignId('product_id')->constrained('catalogue_products')->onDelete('cascade')->onUpdate('cascade');
$table->foreignId('product_id')->constrained('pim_products')->onDelete('cascade')->onUpdate('cascade');
$table->foreignId('property_id')->constrained('pim_property')->onDelete('cascade')->onUpdate('cascade');
$table->text('value');
$table->timestamps();
Expand All @@ -26,6 +26,6 @@ public function up(): void
*/
public function down(): void
{
Schema::dropIfExists('catalogue_product_has_custom_prop_value');
Schema::dropIfExists('pim_product_has_custom_prop_value');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
public function up(): void
{
Schema::table('catalogue_product_data', function (Blueprint $table) {
Schema::table('pim_product_data', function (Blueprint $table) {
$table->foreignId('product_status_id')
->nullable()
->after('product_id')
Expand All @@ -20,7 +20,7 @@ public function up(): void

public function down(): void
{
Schema::table('catalogue_product_data', function (Blueprint $table) {
Schema::table('pim_product_data', function (Blueprint $table) {
$table->dropForeign(['product_status_id']);
$table->dropColumn('product_status_id');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public function table(Table $table): Table
}

// Exclude products already in this group
$existingProductIds = $group->products()->pluck('catalogue_products.id')->toArray();
$query->whereNotIn('catalogue_products.id', $existingProductIds);
$existingProductIds = $group->products()->pluck('pim_products.id')->toArray();
$query->whereNotIn('pim_products.id', $existingProductIds);

return $query->pluck('name', 'id')->toArray();
})
Expand Down Expand Up @@ -135,7 +135,7 @@ public function table(Table $table): Table

$refName = $livewire->getOwnerRecord()
->products()
->where('catalogue_products.id', $refId)
->where('pim_products.id', $refId)
->value('name');

if (! $refName) {
Expand All @@ -155,7 +155,7 @@ public function table(Table $table): Table
$group = $this->getOwnerRecord();

$reference = $group->products()
->where('catalogue_products.id', $data['reference_id'])
->where('pim_products.id', $data['reference_id'])
->firstOrFail();

if ($data['position'] === 'before') {
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Category extends Model
{
use HasFactory, HasTranslations, IsSearchable, ModelTree, SoftDeletes;

protected $table = 'catalogue_categories';
protected $table = 'pim_categories';

protected $fillable = [
'name',
Expand Down
2 changes: 1 addition & 1 deletion src/Models/CustomPropertyValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class CustomPropertyValue extends Model
{
protected $table = 'catalogue_product_has_custom_prop_value';
protected $table = 'pim_product_has_custom_prop_value';

protected $fillable = [
'product_id',
Expand Down
6 changes: 3 additions & 3 deletions src/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Product extends Model implements HasMedia
{
use HasFactory, HasTenantScopedData, HasTranslations, InteractsWithMedia, IsSearchable, SoftDeletes;

protected $table = 'catalogue_products';
protected $table = 'pim_products';

protected $fillable = [
'code',
Expand Down Expand Up @@ -104,7 +104,7 @@ public function type(): BelongsTo

public function propertyValues(): BelongsToMany
{
return $this->belongsToMany(PropertyValue::class, 'catalogue_product_has_property_value', 'product_id', 'property_value_id')
return $this->belongsToMany(PropertyValue::class, 'pim_product_has_property_value', 'product_id', 'property_value_id')
->withTimestamps();
}

Expand All @@ -115,7 +115,7 @@ public function customPropertyValues(): HasMany

public function customProperties(): BelongsToMany
{
return $this->belongsToMany(Property::class, 'catalogue_product_has_custom_prop_value', 'product_id', 'property_id')
return $this->belongsToMany(Property::class, 'pim_product_has_custom_prop_value', 'product_id', 'property_id')
->withPivot('value')
->withTimestamps();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Product/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class Price extends Model
{
protected $table = 'catalogue_product_prices';
protected $table = 'pim_product_prices';

protected $fillable = [
'id',
Expand Down
2 changes: 1 addition & 1 deletion src/Models/ProductData.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ProductData extends Model
{
use HasFactory;

protected $table = 'catalogue_product_data';
protected $table = 'pim_product_data';

public $timestamps = false;

Expand Down
4 changes: 2 additions & 2 deletions src/Models/PropertyValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function property(): BelongsTo

public function products(): BelongsToMany
{
return $this->belongsToMany(Product::class, 'catalogue_product_has_property_value', 'property_value_id', 'product_id')
return $this->belongsToMany(Product::class, 'pim_product_has_property_value', 'property_value_id', 'product_id')
->withTimestamps();
}

Expand Down Expand Up @@ -141,7 +141,7 @@ public function mergeInto(int $targetId): array
throw new \RuntimeException('Values must belong to the same property.');
}

$pivotTable = 'catalogue_product_has_property_value';
$pivotTable = 'pim_product_has_property_value';

$productIds = DB::table($pivotTable)
->where('property_value_id', $this->id)
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/CustomPropertyMultilangTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
$product->setCustomPropertyValue($property, $multilangValue);

// Verify the value is stored as JSON in the database
$this->assertDatabaseHas('catalogue_product_has_custom_prop_value', [
$this->assertDatabaseHas('pim_product_has_custom_prop_value', [
'product_id' => $product->id,
'property_id' => $property->id,
'value' => json_encode($multilangValue),
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/InlineTranslatableFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
$product->setCustomPropertyValue($property, $multilangValue);

// Verify the value is stored as JSON in the database
$this->assertDatabaseHas('catalogue_product_has_custom_prop_value', [
$this->assertDatabaseHas('pim_product_has_custom_prop_value', [
'product_id' => $product->id,
'property_id' => $property->id,
'value' => json_encode($multilangValue),
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/PropertyIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@
expect($product->propertyValues->pluck('id')->toArray())->toContain($value1->id);
expect($product->propertyValues->pluck('id')->toArray())->toContain($value2->id);

$this->assertDatabaseHas('catalogue_product_has_property_value', [
$this->assertDatabaseHas('pim_product_has_property_value', [
'product_id' => $product->id,
'property_value_id' => $value1->id,
]);

$this->assertDatabaseHas('catalogue_product_has_property_value', [
$this->assertDatabaseHas('pim_product_has_property_value', [
'product_id' => $product->id,
'property_value_id' => $value2->id,
]);
Expand Down
Loading