Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c8dcadd
feat(product-types): add migration and prototype model
SlimDeluxe Aug 8, 2025
f3c3f1d
Merge branch 'main' into feat/types
SlimDeluxe Aug 19, 2025
9586084
fix: fix migration
SlimDeluxe Aug 19, 2025
549bbed
feat(properties): implement product properties
KilianTrunk Aug 21, 2025
f29262d
fix: product value fixes on product resource
KilianTrunk Aug 21, 2025
6b59264
fix: more testing fixes
KilianTrunk Aug 21, 2025
85742f7
fix: remove unnecessary code
KilianTrunk Aug 21, 2025
2956340
chore: add seeder to CatalogueSeeder & fix namespace
KilianTrunk Aug 23, 2025
ba8cd95
fix: fix translations
KilianTrunk Aug 23, 2025
9e91b68
fix: fix breadcrumbs & add more translations
KilianTrunk Aug 23, 2025
80a8fb3
fix: db structure fixes
KilianTrunk Aug 23, 2025
7a0b436
fix: max values fix
KilianTrunk Aug 23, 2025
5d25af8
style: fix code style
KilianTrunk Aug 23, 2025
07531f8
chore: more improvements
KilianTrunk Aug 23, 2025
f79158a
Merge branch 'feat/properties' of github.com:KilianTrunk/eclipsephp-c…
KilianTrunk Aug 23, 2025
18ce832
chore: product type fixes & removage of sort column
KilianTrunk Aug 23, 2025
799c9b9
chore: update sorting of product type
KilianTrunk Aug 23, 2025
7fae8ec
chore: improve sorting reordering for property values
KilianTrunk Aug 23, 2025
d6ecc8e
chore: set default property
KilianTrunk Aug 23, 2025
6e42b4f
fix: fix reordering for property value
KilianTrunk Aug 23, 2025
0d3e655
Merge branch 'main' into feat/properties
KilianTrunk Aug 25, 2025
cd784e6
fix: fix
KilianTrunk Aug 25, 2025
f2723e5
chore: property values improvements
KilianTrunk Aug 28, 2025
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
@@ -0,0 +1,37 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('pim_property', function (Blueprint $table) {
$table->id();
$table->string('code', 50)->nullable()->unique();
$table->string('name');
$table->mediumText('description')->nullable();
$table->string('internal_name')->nullable();
$table->boolean('is_active')->default(true);
$table->boolean('is_global')->default(false);
$table->tinyInteger('max_values')->nullable();
$table->boolean('enable_sorting')->default(false);
$table->boolean('is_filter')->default(false);
$table->timestamps();
$table->softDeletes();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('pim_property');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('pim_property_value', function (Blueprint $table) {
$table->id();
$table->foreignId('property_id')->constrained('pim_property')->onDelete('cascade')->onUpdate('cascade');
$table->string('value');
$table->smallInteger('sort')->default(0);
$table->string('info_url')->nullable();
$table->string('image')->nullable();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('pim_property_value');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('pim_product_type_has_property', function (Blueprint $table) {
$table->foreignId('product_type_id')->constrained('pim_product_types')->onDelete('cascade')->onUpdate('cascade');
$table->foreignId('property_id')->constrained('pim_property')->onDelete('cascade')->onUpdate('cascade');
$table->smallInteger('sort')->nullable();
$table->timestamps();
$table->primary(['product_type_id', 'property_id']);
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('pim_product_type_has_property');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
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');
$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');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('catalogue_product_has_property_value');
}
};
1 change: 1 addition & 0 deletions database/seeders/CatalogueSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function run(): void
{
$this->call(CategorySeeder::class);
$this->call(ProductTypeSeeder::class);
$this->call(PropertySeeder::class);
$this->call(ProductSeeder::class);
}
}
117 changes: 117 additions & 0 deletions database/seeders/PropertySeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?php

namespace Eclipse\Catalogue\Seeders;

use Eclipse\Catalogue\Models\ProductType;
use Eclipse\Catalogue\Models\Property;
use Eclipse\Catalogue\Models\PropertyValue;
use Illuminate\Database\Seeder;

class PropertySeeder extends Seeder
{
public function run(): void
{
// Create Brand property (global)
$brandProperty = Property::create([
'code' => 'brand',
'name' => ['en' => 'Brand'],
'description' => ['en' => 'Product brand or manufacturer'],
'internal_name' => 'Brand/Manufacturer',
'is_active' => true,
'is_global' => true,
'max_values' => 1,
'enable_sorting' => false,
'is_filter' => true,
]);

// Create brand values
$brands = ['Nike', 'Adidas', 'Apple', 'Samsung', 'Sony'];
foreach ($brands as $index => $brand) {
PropertyValue::create([
'property_id' => $brandProperty->id,
'value' => ['en' => $brand],
'sort' => $index * 10,
]);
}

// Create Color property (global)
$colorProperty = Property::create([
'code' => 'color',
'name' => ['en' => 'Color'],
'description' => ['en' => 'Product color'],
'is_active' => true,
'is_global' => true,
'max_values' => 3, // Allow multiple colors
'enable_sorting' => true,
'is_filter' => true,
]);

// Create color values
$colors = ['Red', 'Blue', 'Green', 'Black', 'White', 'Yellow', 'Purple', 'Orange'];
foreach ($colors as $index => $color) {
PropertyValue::create([
'property_id' => $colorProperty->id,
'value' => ['en' => $color],
'sort' => $index * 10,
]);
}

// Create Size property (for clothing type only)
$sizeProperty = Property::create([
'code' => 'size',
'name' => ['en' => 'Size'],
'description' => ['en' => 'Clothing size'],
'is_active' => true,
'is_global' => false,
'max_values' => 1,
'enable_sorting' => true,
'is_filter' => true,
]);

// Create size values
$sizes = ['XS', 'S', 'M', 'L', 'XL', 'XXL'];
foreach ($sizes as $index => $size) {
PropertyValue::create([
'property_id' => $sizeProperty->id,
'value' => ['en' => $size],
'sort' => $index * 10,
]);
}

// Create Material property
$materialProperty = Property::create([
'code' => 'material',
'name' => ['en' => 'Material'],
'description' => ['en' => 'Product material composition'],
'is_active' => true,
'is_global' => false,
'max_values' => 2, // Allow multiple materials
'enable_sorting' => false,
'is_filter' => true,
]);

// Create material values
$materials = ['Cotton', 'Polyester', 'Wool', 'Silk', 'Leather', 'Plastic', 'Metal', 'Wood'];
foreach ($materials as $index => $material) {
PropertyValue::create([
'property_id' => $materialProperty->id,
'value' => ['en' => $material],
'sort' => $index * 10,
]);
}

// If there are product types, assign non-global properties to some of them
$productTypes = ProductType::all();
if ($productTypes->isNotEmpty()) {
// Assign size to first product type (assuming it's clothing)
if ($productTypes->count() > 0) {
$productTypes->first()->properties()->attach($sizeProperty->id, ['sort' => 10]);
}

// Assign material to first two product types
foreach ($productTypes->take(2) as $index => $productType) {
$productType->properties()->attach($materialProperty->id, ['sort' => 20]);
}
}
}
}
69 changes: 69 additions & 0 deletions resources/lang/en/property-value.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

return [
'singular' => 'Property Value',
'plural' => 'Property Values',

'fields' => [
'value' => 'Value',
'info_url' => 'Info URL',
'image' => 'Image',
'sort' => 'Sort Order',
],

'sections' => [
'value_information' => 'Value Information',
],

'placeholders' => [
'value' => 'Enter property value',
'info_url' => 'Enter optional "read more" link',
'sort' => 'Enter sort order (lower numbers appear first)',
],

'help_text' => [
'info_url' => 'Optional "read more" link',
'image' => 'Optional image for this value (e.g., brand logo)',
'sort' => 'Lower numbers appear first',
],

'table' => [
'columns' => [
'value' => 'Value',
'image' => 'Image',
'info_url' => 'Info URL',
'sort' => 'Sort',
'products_count' => 'Products',
'created_at' => 'Created',
],
'filters' => [
'property' => 'Property',
],
'actions' => [
'edit' => 'Edit',
'delete' => 'Delete',
],
],

'modal' => [
'create_heading' => 'Create Property Value',
'edit_heading' => 'Edit Property Value',
],

'messages' => [
'created' => 'Property value created successfully.',
'updated' => 'Property value updated successfully.',
'deleted' => 'Property value deleted successfully.',
],

'pages' => [
'title' => [
'with_property' => 'Values for: :property',
'default' => 'Property Values',
],
'breadcrumbs' => [
'properties' => 'Properties',
'list' => 'List',
],
],
];
Loading