Skip to content

Commit b458318

Browse files
committed
Merge branch 'support/laravel-13' into 4.x
2 parents 2890fe6 + 3e2bf22 commit b458318

5 files changed

Lines changed: 85 additions & 10 deletions

File tree

.github/workflows/test-matrix.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Test Matrix
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- '[0-9]+.x' # Trigger for main version branch (e.g. 1.x, 2.x, 3.x, 4.x)
8+
- support/*
9+
10+
jobs:
11+
tests:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
php: ['8.2', '8.3']
17+
laravel: ['^12.0', '^13.0']
18+
exclude:
19+
- php: '8.2'
20+
laravel: '^13.0'
21+
22+
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
23+
24+
steps:
25+
- uses: actions/checkout@v5
26+
27+
- name: Setup PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: ${{ matrix.php }}
31+
extensions: mbstring, pdo, sqlite, curl, dom, fileinfo, gd, intl
32+
coverage: none
33+
34+
- name: Validate composer
35+
run: composer validate --strict
36+
37+
- name: Configure Laravel version
38+
run: composer require "laravel/framework:${{ matrix.laravel }}" --no-update --with-all-dependencies
39+
40+
- name: Install dependencies
41+
run: composer update --prefer-dist --no-interaction --no-progress --with-all-dependencies
42+
43+
- name: Run tests
44+
run: vendor/bin/pest --no-coverage

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
],
2222
"require": {
2323
"php": ">=8.2",
24-
"laravel/framework": "^11.0|^12.0",
24+
"laravel/framework": "^11.0|^12.0|^13.0",
2525
"filament/filament": "^4.0",
26-
"kalnoy/nestedset": "^6.0",
26+
"kalnoy/nestedset": "^6.0|^7.0",
2727
"php-ffmpeg/php-ffmpeg": "^1.2",
28-
"spatie/eloquent-sortable": "^4.4",
28+
"spatie/eloquent-sortable": "^5.0",
2929
"spatie/laravel-medialibrary": "^10.0|^11.0",
3030
"spatie/laravel-package-tools": "^1.15.0",
3131
"staudenmeir/laravel-adjacency-list": "^1.0"
@@ -34,11 +34,11 @@
3434
"larastan/larastan": "^3.0",
3535
"laravel/pint": "^1.0",
3636
"nunomaduro/collision": "^8.0",
37-
"orchestra/testbench": "^9.0|^10.0",
38-
"pestphp/pest": "^3.0",
39-
"pestphp/pest-plugin-arch": "^3.0",
40-
"pestphp/pest-plugin-laravel": "^3.0",
41-
"pestphp/pest-plugin-livewire": "^3.0",
37+
"orchestra/testbench": "^9.0|^10.0|^11.0",
38+
"pestphp/pest": "^3.0|^4.0",
39+
"pestphp/pest-plugin-arch": "^3.0|^4.0",
40+
"pestphp/pest-plugin-laravel": "^3.0|^4.0",
41+
"pestphp/pest-plugin-livewire": "^3.0|^4.0",
4242
"phpstan/extension-installer": "^1.1",
4343
"phpstan/phpstan-deprecation-rules": "^2.0",
4444
"phpstan/phpstan-phpunit": "^2.0",

src/Models/Concerns/BelongsToNestableTree.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ trait BelongsToNestableTree
1414
{
1515
public static function bootBelongsToNestableTree()
1616
{
17-
static::observe(new BelongsToNestableTreeObserver);
17+
// Instead of observe(), register the each event listener separately for support Laravel 13
18+
static::created(fn ($model) => (new BelongsToNestableTreeObserver)->created($model));
19+
static::updated(fn ($model) => (new BelongsToNestableTreeObserver)->updated($model));
20+
static::deleting(fn ($model) => (new BelongsToNestableTreeObserver)->deleting($model));
21+
if (in_array('Illuminate\Database\Eloquent\SoftDeletes', class_uses_recursive(static::class))) {
22+
static::forceDeleting(fn ($model) => (new BelongsToNestableTreeObserver)->forceDeleting($model));
23+
}
24+
// static::observe(new BelongsToNestableTreeObserver);
1825
}
1926

2027
/**

src/Models/Concerns/HasRecursiveRelationships.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ trait HasRecursiveRelationships
1515

1616
public static function bootHasRecursiveRelationships()
1717
{
18-
static::observe(new HasRecursiveRelationshipsObserver);
18+
// Instead of observe(), register the each event listener separately for support Laravel 13
19+
static::creating(fn ($model) => (new HasRecursiveRelationshipsObserver)->creating($model));
20+
static::deleting(fn ($model) => (new HasRecursiveRelationshipsObserver)->deleting($model));
21+
if (in_array('Illuminate\Database\Eloquent\SoftDeletes', class_uses_recursive(static::class))) {
22+
static::restoring(fn ($model) => (new HasRecursiveRelationshipsObserver)->restoring($model));
23+
static::forceDeleting(fn ($model) => (new HasRecursiveRelationshipsObserver)->forceDeleting($model));
24+
}
25+
// static::observe(new HasRecursiveRelationshipsObserver);
1926
}
2027

2128
/**

tests/src/Unit/Models/MediaAssetTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@
1414
$this->dummyRandImageUrl = 'https://picsum.photos/200/300';
1515
});
1616

17+
it('boots media asset lifecycle without recursive boot errors', function () {
18+
$mediaAsset = MediaAsset::factory()->isFolder()->create()->refresh();
19+
20+
$mediaAsset->title = 'Boot Lifecycle Updated';
21+
$mediaAsset->save();
22+
23+
$mediaAsset->delete();
24+
if (method_exists($mediaAsset, 'restore')) {
25+
$mediaAsset->restore();
26+
}
27+
if (method_exists($mediaAsset, 'forceDelete')) {
28+
$mediaAsset->forceDelete();
29+
}
30+
31+
expect(true)->toBeTrue();
32+
});
33+
1734
dataset('image_extensions', [
1835
'jpg' => ['jpg'],
1936
'png' => ['png'],

0 commit comments

Comments
 (0)