Skip to content

Commit f3c3f1d

Browse files
committed
Merge branch 'main' into feat/types
# Conflicts: # database/migrations/2025_08_08_082024_create_product_types_table.php
2 parents c8dcadd + 59dd41c commit f3c3f1d

54 files changed

Lines changed: 4518 additions & 37 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/linter.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ jobs:
2222
- name: Checkout code
2323
uses: actions/checkout@v4
2424
with:
25-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
25+
# Checkout the actual branch, not a specific commit
26+
ref: ${{ github.head_ref || github.ref_name }}
27+
# Fetch the full history to avoid shallow clone issues
28+
fetch-depth: 0
2629

2730
- name: Run Laravel Pint
2831
uses: aglipanci/laravel-pint-action@latest

.github/workflows/release-please.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/test-runner.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,24 @@ permissions:
1919
jobs:
2020
test:
2121

22-
runs-on: ${{ matrix.os }}
22+
runs-on: ubuntu-latest
2323

24-
# Define the matrix of different PHP and dependency versions
24+
# Define the matrix of different PHP, Laravel, and testbench versions
2525
strategy:
2626
# Fail the whole workflow if one of the jobs fails
2727
fail-fast: true
2828
matrix:
29-
os: [ ubuntu-latest ]
3029
php: [ 8.2, 8.3, 8.4 ]
31-
dependency-version: [ prefer-lowest, prefer-stable ]
32-
33-
name: ${{ matrix.os }} / PHP ${{ matrix.php }} / ${{ matrix.dependency-version }}
30+
laravel: [ 11.*, 12.* ]
31+
dependency-version: [ prefer-stable ]
32+
include:
33+
# Laravel 12 uses Orchestra Testbench 10
34+
- laravel: 12.*
35+
testbench: 10.*
36+
# Laravel 11 uses Orchestra Testbench 9
37+
- laravel: 11.*
38+
testbench: 9.*
39+
name: PHP ${{ matrix.php }} / L${{ matrix.laravel }} / ${{ matrix.dependency-version }}
3440

3541
steps:
3642

@@ -51,7 +57,7 @@ jobs:
5157
uses: actions/cache@v3
5258
with:
5359
path: vendor
54-
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.dependency-version }}-${{ hashFiles('**/composer.lock') }}
60+
key: php-${{ matrix.php }}-laravel-${{ matrix.laravel }}-${{ matrix.dependency-version }}-${{ hashFiles('**/composer.lock') }}
5561

5662
- name: Setup PHP
5763
uses: shivammathur/setup-php@v2
@@ -61,14 +67,16 @@ jobs:
6167
# extensions: mbstring, gd, intl
6268

6369
- name: Install dependencies
64-
run: composer update --prefer-dist --no-progress --${{ matrix.dependency-version }}
70+
run: |
71+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "filament/support:^3.3" --no-interaction --no-update
72+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-progress --no-interaction
6573
6674
- name: Run test suite
6775
run: composer test -- --coverage-clover ./coverage.xml
6876

6977
- name: Upload coverage reports to Codecov
7078
# Make sure the Codecov action is only executed once
71-
if: matrix.os == 'ubuntu-latest' && matrix.php == '8.2' && matrix.dependency-version == 'prefer-stable'
79+
if: matrix.php == '8.2' && matrix.laravel == '12.*' && matrix.dependency-version == 'prefer-stable'
7280
uses: codecov/codecov-action@v5
7381
with:
7482
token: ${{ secrets.CODECOV_TOKEN }}

.lando.dist.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#file: noinspection ComposeUnknownKeys
1+
#file: noinspection ComposeUnknownKeys,YAMLSchemaValidation
22
name: eclipse-catalogue
33
services:
44
appserver:
55
type: php:custom
66
xdebug: "debug,develop,coverage"
77
via: cli
88
overrides:
9-
image: slimdeluxe/php:8.2-v1.1
9+
image: slimdeluxe/php:8.2-v1.3
1010
tooling:
1111
php:
1212
service: appserver

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,19 @@
4848
"bezhansalleh/filament-shield": "^3.3",
4949
"datalinx/php-utils": "^2.5",
5050
"eclipsephp/common": "dev-main",
51+
"eclipsephp/world-plugin": "dev-main",
5152
"filament/filament": "^3.3",
5253
"filament/spatie-laravel-media-library-plugin": "^3.2",
5354
"filament/spatie-laravel-translatable-plugin": "^3.2",
55+
"laravel/framework": "^11.0|^12.0",
5456
"solution-forest/filament-tree": "^2.1",
5557
"spatie/laravel-package-tools": "^1.19",
56-
"spatie/laravel-translatable": "^6.11"
58+
"spatie/laravel-translatable": "^6.11",
59+
"nben/filament-record-nav": "^1.0"
5760
},
5861
"require-dev": {
5962
"laravel/pint": "^1.21",
60-
"orchestra/testbench": "^10.1",
63+
"orchestra/testbench": "^9.0|^10.1",
6164
"pestphp/pest": "^3.7",
6265
"pestphp/pest-plugin-livewire": "^3.0"
6366
},
@@ -79,6 +82,7 @@
7982
"@php vendor/bin/testbench serve --ansi"
8083
],
8184
"setup": [
85+
"npm install",
8286
"@php vendor/bin/testbench vendor:publish --provider='Spatie\\Permission\\PermissionServiceProvider'",
8387
"@php vendor/bin/testbench vendor:publish --tag='filament-shield-config'",
8488
"@php vendor/bin/testbench vendor:publish --provider='Laravel\\Scout\\ScoutServiceProvider'",
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace Eclipse\Catalogue\Factories;
4+
5+
use Eclipse\Catalogue\Models\PriceList;
6+
use Eclipse\Catalogue\Models\PriceListData;
7+
use Illuminate\Database\Eloquent\Factories\Factory;
8+
9+
/**
10+
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Eclipse\Catalogue\Models\PriceListData>
11+
*/
12+
class PriceListDataFactory extends Factory
13+
{
14+
protected $model = PriceListData::class;
15+
16+
public function definition(): array
17+
{
18+
$definition = [
19+
'price_list_id' => PriceList::factory(),
20+
'is_active' => $this->faker->boolean(80), // 80% chance of being active
21+
'is_default' => false,
22+
'is_default_purchase' => false,
23+
];
24+
25+
// Add tenant foreign key if configured
26+
if (config('eclipse-catalogue.tenancy.foreign_key')) {
27+
$tenantModel = config('eclipse-catalogue.tenancy.model');
28+
if (class_exists($tenantModel)) {
29+
$definition[config('eclipse-catalogue.tenancy.foreign_key')] = $tenantModel::factory();
30+
}
31+
}
32+
33+
return $definition;
34+
}
35+
36+
public function active(): static
37+
{
38+
return $this->state(fn (array $attributes) => [
39+
'is_active' => true,
40+
]);
41+
}
42+
43+
public function inactive(): static
44+
{
45+
return $this->state(fn (array $attributes) => [
46+
'is_active' => false,
47+
]);
48+
}
49+
50+
public function defaultSelling(): static
51+
{
52+
return $this->state(fn (array $attributes) => [
53+
'is_default' => true,
54+
'is_default_purchase' => false,
55+
]);
56+
}
57+
58+
public function defaultPurchase(): static
59+
{
60+
return $this->state(fn (array $attributes) => [
61+
'is_default' => false,
62+
'is_default_purchase' => true,
63+
]);
64+
}
65+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace Eclipse\Catalogue\Factories;
4+
5+
use Eclipse\Catalogue\Models\PriceList;
6+
use Eclipse\World\Models\Currency;
7+
use Illuminate\Database\Eloquent\Factories\Factory;
8+
9+
/**
10+
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Eclipse\Catalogue\Models\PriceList>
11+
*/
12+
class PriceListFactory extends Factory
13+
{
14+
protected $model = PriceList::class;
15+
16+
public function definition(): array
17+
{
18+
// Get existing currencies or create a default one
19+
$currencies = Currency::all();
20+
if ($currencies->isEmpty()) {
21+
Currency::create(['id' => 'EUR', 'name' => 'Euro', 'is_active' => true]);
22+
$currencies = Currency::all();
23+
}
24+
25+
return [
26+
'currency_id' => $currencies->random()->id,
27+
'name' => $this->faker->words(2, true).' Price List',
28+
'code' => strtoupper($this->faker->unique()->lexify('PL???')),
29+
'tax_included' => $this->faker->boolean(),
30+
'notes' => $this->faker->optional()->sentence(),
31+
];
32+
}
33+
34+
public function withTaxIncluded(): static
35+
{
36+
return $this->state(fn (array $attributes) => [
37+
'tax_included' => true,
38+
]);
39+
}
40+
41+
public function withoutTax(): static
42+
{
43+
return $this->state(fn (array $attributes) => [
44+
'tax_included' => false,
45+
]);
46+
}
47+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
public function up(): void
10+
{
11+
Schema::create('pim_price_lists', function (Blueprint $table) {
12+
$table->id();
13+
$table->string('currency_id', 3);
14+
$table->foreign('currency_id')
15+
->references('id')
16+
->on('world_currencies')
17+
->cascadeOnUpdate()
18+
->restrictOnDelete();
19+
$table->string('name');
20+
$table->string('code')->nullable();
21+
$table->boolean('tax_included');
22+
$table->string('notes')->nullable();
23+
$table->timestamps();
24+
$table->softDeletes();
25+
});
26+
27+
// More price list data, optionally in tenant-scope
28+
Schema::create('pim_price_list_data', function (Blueprint $table) {
29+
$table->id();
30+
$table->foreignId('price_list_id')
31+
->constrained('pim_price_lists')
32+
->cascadeOnUpdate()
33+
->cascadeOnDelete();
34+
35+
// Add foreign key for tenant if it's configured in the catalogue config
36+
if (config('eclipse-catalogue.tenancy.model')) {
37+
$tenantClass = config('eclipse-catalogue.tenancy.model');
38+
/** @var \Illuminate\Database\Eloquent\Model $tenant */
39+
$tenant = new $tenantClass;
40+
$table->foreignId(config('eclipse-catalogue.tenancy.foreign_key'))
41+
->constrained($tenant->getTable(), $tenant->getKeyName())
42+
->cascadeOnUpdate()
43+
->cascadeOnDelete();
44+
}
45+
46+
$table->boolean('is_active')->default(true);
47+
$table->boolean('is_default')->default(false);
48+
$table->boolean('is_default_purchase')->default(false);
49+
});
50+
}
51+
52+
public function down(): void
53+
{
54+
Schema::dropIfExists('pim_price_list_data');
55+
Schema::dropIfExists('pim_price_lists');
56+
}
57+
};

database/migrations/2025_08_08_082024_create_product_types_table.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
return new class extends Migration {
87
public function up(): void
98
{
109
Schema::create('pim_product_types', function (Blueprint $table) {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
public function up(): void
10+
{
11+
Schema::table('catalogue_products', function (Blueprint $table) {
12+
$table->foreignId('product_type_id')
13+
->nullable()
14+
->after('category_id')
15+
->constrained('pim_product_types')
16+
->cascadeOnUpdate()
17+
->restrictOnDelete();
18+
});
19+
}
20+
21+
public function down(): void
22+
{
23+
Schema::table('catalogue_products', function (Blueprint $table) {
24+
$table->dropForeign(['product_type_id']);
25+
$table->dropColumn('product_type_id');
26+
});
27+
}
28+
};

0 commit comments

Comments
 (0)