From 5c5d9fe2dfae019fd9f5032bb884499aef5ee9fb Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Tue, 26 Nov 2024 10:55:35 +0100 Subject: [PATCH 1/8] move declaration of state-model from general config to state-config --- app/ModelStates/ModelStates/ModelState.php | 8 ++++++++ .../OtherModelStates/OtherModelState.php | 8 ++++++++ phpstan.neon | 1 - src/ModelStates/HasStateManager.php | 4 ++-- src/ModelStates/HasStateManagerInterface.php | 1 + src/ModelStates/ModelStatesServiceProvider.php | 13 ------------- src/ModelStates/State.php | 4 ++++ src/ModelStates/model-state.php | 10 ---------- 8 files changed, 23 insertions(+), 26 deletions(-) diff --git a/app/ModelStates/ModelStates/ModelState.php b/app/ModelStates/ModelStates/ModelState.php index 05702fb..95ec5d5 100644 --- a/app/ModelStates/ModelStates/ModelState.php +++ b/app/ModelStates/ModelStates/ModelState.php @@ -2,6 +2,8 @@ namespace App\ModelStates\ModelStates; +use App\ModelStates\StateManager; +use Illuminate\Database\Eloquent\Model; use MLL\LaravelUtils\ModelStates\State; use MLL\LaravelUtils\ModelStates\StateConfig; @@ -19,4 +21,10 @@ public static function defaultState(): ModelState { return new StateA(); } + + /** @return class-string */ + public static function stateManagerClass(): string + { + return StateManager::class; + } } diff --git a/app/ModelStates/OtherModelStates/OtherModelState.php b/app/ModelStates/OtherModelStates/OtherModelState.php index 3f7954a..7ce5934 100644 --- a/app/ModelStates/OtherModelStates/OtherModelState.php +++ b/app/ModelStates/OtherModelStates/OtherModelState.php @@ -2,8 +2,10 @@ namespace App\ModelStates\OtherModelStates; +use App\ModelStates\StateManager; use App\ModelStates\Transitions\CustomInvalidTransition; use App\ModelStates\Transitions\CustomTransition; +use Illuminate\Database\Eloquent\Model; use MLL\LaravelUtils\ModelStates\State; use MLL\LaravelUtils\ModelStates\StateConfig; @@ -20,4 +22,10 @@ public static function defaultState(): OtherModelState { return new StateX(); } + + /** @return class-string */ + public static function stateManagerClass(): string + { + return StateManager::class; + } } diff --git a/phpstan.neon b/phpstan.neon index 9766147..7d72486 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,7 +3,6 @@ parameters: paths: - src - tests - checkGenericClassInNonGenericObjectType: false # TODO reenable once we require Laravel 9+ reportUnmatchedIgnoredErrors: false # As long as we support multiple Laravel versions at once, there will be some dead spots ignoreErrors: # PHPStan does not believe interfaces can define magic properties diff --git a/src/ModelStates/HasStateManager.php b/src/ModelStates/HasStateManager.php index 057b76e..2e1facd 100644 --- a/src/ModelStates/HasStateManager.php +++ b/src/ModelStates/HasStateManager.php @@ -17,7 +17,7 @@ public static function bootHasStateManager(): void return; } - $stateManagerClass = ModelStatesServiceProvider::stateManagerClass(); + $stateManagerClass = $self->stateClass()::stateManagerClass(); $stateManager = new $stateManagerClass(); $stateManager->setAttribute(ModelStatesServiceProvider::stateColumnName(), $self->stateClass()::defaultState()::name()); @@ -55,7 +55,7 @@ public function setStateAttribute(State|string $newState): void public function stateManager(): MorphOne { return $this->morphOne( - ModelStatesServiceProvider::stateManagerClass(), + $this->stateClass()::stateManagerClass(), 'stateable', ); } diff --git a/src/ModelStates/HasStateManagerInterface.php b/src/ModelStates/HasStateManagerInterface.php index 5de2a52..986b3f8 100644 --- a/src/ModelStates/HasStateManagerInterface.php +++ b/src/ModelStates/HasStateManagerInterface.php @@ -11,6 +11,7 @@ */ interface HasStateManagerInterface { + /** @phpstan-ignore missingType.generics (declaring type not specified here on purpose because it is an interface) */ public function stateManager(): MorphOne; /** @return class-string */ diff --git a/src/ModelStates/ModelStatesServiceProvider.php b/src/ModelStates/ModelStatesServiceProvider.php index 993695d..28ab670 100644 --- a/src/ModelStates/ModelStatesServiceProvider.php +++ b/src/ModelStates/ModelStatesServiceProvider.php @@ -19,19 +19,6 @@ public function boot(): void $this->mergeConfigFrom($configFile, 'model-state'); } - /** @return class-string */ - public static function stateManagerClass(): string - { - $config = Container::getInstance()->make(ConfigRepository::class); - // @phpstan-ignore-next-line unknown with Laravel 8, known with Laravel 9 - assert($config instanceof ConfigRepository); - - $modelClass = $config->get('model-state.model'); - assert(is_string($modelClass) && is_subclass_of($modelClass, Model::class)); - - return $modelClass; - } - public static function stateColumnName(): string { $config = Container::getInstance()->make(ConfigRepository::class); diff --git a/src/ModelStates/State.php b/src/ModelStates/State.php index dfc0f86..3bbf52a 100644 --- a/src/ModelStates/State.php +++ b/src/ModelStates/State.php @@ -2,6 +2,7 @@ namespace MLL\LaravelUtils\ModelStates; +use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Str; abstract class State @@ -10,6 +11,9 @@ abstract public static function config(): StateConfig; abstract public static function defaultState(): self; + /** @return class-string */ + abstract public static function stateManagerClass(): string; + public static function name(): string { $stateClassBaseName = (new \ReflectionClass(get_called_class()))->getShortName(); diff --git a/src/ModelStates/model-state.php b/src/ModelStates/model-state.php index 598b11e..1d95559 100644 --- a/src/ModelStates/model-state.php +++ b/src/ModelStates/model-state.php @@ -1,16 +1,6 @@ App\ModelStates\StateManager::class, - /* |-------------------------------------------------------------------------- | State Column Name From 04c1a8a0a17d90b35c9b9a3b32ecc47ef42778e3 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Tue, 26 Nov 2024 11:28:34 +0100 Subject: [PATCH 2/8] move declaration of state-column-name from general config to state class --- app/ModelStates/StateManager.php | 5 +++ .../2022_12_28_012345_state_test_models.php | 4 +-- composer.json | 3 +- src/ModelStates/HasStateManager.php | 10 ++++-- src/ModelStates/IsStateManager.php | 2 ++ .../ModelStatesServiceProvider.php | 33 ------------------- src/ModelStates/Transition.php | 2 +- src/ModelStates/model-state.php | 13 -------- tests/DBTestCase.php | 2 -- 9 files changed, 18 insertions(+), 56 deletions(-) delete mode 100644 src/ModelStates/ModelStatesServiceProvider.php delete mode 100644 src/ModelStates/model-state.php diff --git a/app/ModelStates/StateManager.php b/app/ModelStates/StateManager.php index 98c1df6..763a0e1 100644 --- a/app/ModelStates/StateManager.php +++ b/app/ModelStates/StateManager.php @@ -17,4 +17,9 @@ public function stateable(): MorphTo { return $this->morphTo(); } + + public static function stateColumnName(): string + { + return 'state_name'; + } } diff --git a/app/migrations/2022_12_28_012345_state_test_models.php b/app/migrations/2022_12_28_012345_state_test_models.php index ad94799..6b199aa 100644 --- a/app/migrations/2022_12_28_012345_state_test_models.php +++ b/app/migrations/2022_12_28_012345_state_test_models.php @@ -1,9 +1,9 @@ increments('id'); $table->morphs('stateable'); - $table->string(ModelStatesServiceProvider::stateColumnName()); + $table->string(StateManager::stateColumnName()); $table->timestamps(); }); } diff --git a/composer.json b/composer.json index fefbf78..c425b3f 100644 --- a/composer.json +++ b/composer.json @@ -72,8 +72,7 @@ "providers": [ "MLL\\LaravelUtils\\LaravelUtilsServiceProvider", "MLL\\LaravelUtils\\Database\\DatabaseServiceProvider", - "MLL\\LaravelUtils\\Mail\\MailServiceProvider", - "MLL\\LaravelUtils\\ModelStates\\ModelStatesServiceProvider" + "MLL\\LaravelUtils\\Mail\\MailServiceProvider" ] } } diff --git a/src/ModelStates/HasStateManager.php b/src/ModelStates/HasStateManager.php index 2e1facd..e59762e 100644 --- a/src/ModelStates/HasStateManager.php +++ b/src/ModelStates/HasStateManager.php @@ -19,7 +19,8 @@ public static function bootHasStateManager(): void $stateManagerClass = $self->stateClass()::stateManagerClass(); $stateManager = new $stateManagerClass(); - $stateManager->setAttribute(ModelStatesServiceProvider::stateColumnName(), $self->stateClass()::defaultState()::name()); + assert(in_array(IsStateManager::class, class_uses($stateManager))); + $stateManager->setAttribute($stateManager::stateColumnName(), $self->stateClass()::defaultState()::name()); $self->stateManager()->save($stateManager); $self->setRelation('stateManager', $stateManager); @@ -28,10 +29,13 @@ public static function bootHasStateManager(): void public function getStateAttribute(): State { - $stateClasses = $this->stateClassConfig()->possibleStates(); - $stateName = $this->stateManager->getAttribute(ModelStatesServiceProvider::stateColumnName()); + $stateManagerClass = $this->stateClass()::stateManagerClass(); + $stateManager = new $stateManagerClass(); + assert(in_array(IsStateManager::class, class_uses($stateManager))); + $stateName = $this->stateManager->getAttribute($stateManager::stateColumnName()); assert(is_string($stateName)); + $stateClasses = $this->stateClassConfig()->possibleStates(); $stateClass = $stateClasses[$stateName] ?? null; if ($stateClass === null) { throw new UnknownStateException("The state {$stateName} of {$this->table} with id {$this->id} is not part of {$this->stateClass()}."); diff --git a/src/ModelStates/IsStateManager.php b/src/ModelStates/IsStateManager.php index 772f2d2..891f61c 100644 --- a/src/ModelStates/IsStateManager.php +++ b/src/ModelStates/IsStateManager.php @@ -17,6 +17,8 @@ trait IsStateManager /** @return MorphTo */ abstract public function stateable(): MorphTo; + abstract public static function stateColumnName(): string; + /** @return SupportCollection, State> */ public function getCanTransitionToAttribute(): SupportCollection { diff --git a/src/ModelStates/ModelStatesServiceProvider.php b/src/ModelStates/ModelStatesServiceProvider.php deleted file mode 100644 index 28ab670..0000000 --- a/src/ModelStates/ModelStatesServiceProvider.php +++ /dev/null @@ -1,33 +0,0 @@ -publishes([ - $configFile => config_path('model-state.php'), - ], 'config'); - $this->mergeConfigFrom($configFile, 'model-state'); - } - - public static function stateColumnName(): string - { - $config = Container::getInstance()->make(ConfigRepository::class); - // @phpstan-ignore-next-line unknown with Laravel 8, known with Laravel 9 - assert($config instanceof ConfigRepository); - - $columnName = $config->get('model-state.column_name'); - assert(is_string($columnName)); - - return $columnName; - } -} diff --git a/src/ModelStates/Transition.php b/src/ModelStates/Transition.php index 8ee03ae..6544d37 100644 --- a/src/ModelStates/Transition.php +++ b/src/ModelStates/Transition.php @@ -48,7 +48,7 @@ public function from(): State /** Can be reused in default state transitions. */ final protected function manage(): void { - $this->model->stateManager->setAttribute(ModelStatesServiceProvider::stateColumnName(), $this->to::name()); + $this->model->stateManager->setAttribute($this->model->stateManager::stateColumnName(), $this->to::name()); $this->model->stateManager->save(); } } diff --git a/src/ModelStates/model-state.php b/src/ModelStates/model-state.php deleted file mode 100644 index 1d95559..0000000 --- a/src/ModelStates/model-state.php +++ /dev/null @@ -1,13 +0,0 @@ - 'state_name', -]; diff --git a/tests/DBTestCase.php b/tests/DBTestCase.php index 63b2abc..0e5216f 100644 --- a/tests/DBTestCase.php +++ b/tests/DBTestCase.php @@ -5,7 +5,6 @@ use Illuminate\Contracts\Config\Repository as ConfigRepository; use Illuminate\Support\Facades\DB; use MLL\LaravelUtils\Database\DatabaseServiceProvider; -use MLL\LaravelUtils\ModelStates\ModelStatesServiceProvider; abstract class DBTestCase extends TestCase { @@ -58,7 +57,6 @@ protected function getPackageProviders($app): array return [ ...parent::getPackageProviders($app), DatabaseServiceProvider::class, - ModelStatesServiceProvider::class, ]; } From 1bb36006315fa4bf6b352cc62b28769e3ae308f7 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Tue, 26 Nov 2024 11:35:39 +0100 Subject: [PATCH 3/8] CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 143b5ef..3461fd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,12 @@ See [GitHub releases](https://github.com/mll-lab/laravel-utils/releases). ## Unreleased +## v9.0.0 + +### Changed + +- Support multiple `StateManager` classes by configuring the `StateManager`-Model in `StateConfig` and the column name in `StateManager`-Model + ## v8.0.0 ### Changed From 795288a23655e64120f2b0e1e40d0a49478fdd01 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Tue, 26 Nov 2024 11:43:30 +0100 Subject: [PATCH 4/8] direct use of instance instead of class name of model --- app/ModelStates/ModelStates/ModelState.php | 5 ++--- app/ModelStates/OtherModelStates/OtherModelState.php | 5 ++--- src/ModelStates/HasStateManager.php | 7 +++---- src/ModelStates/State.php | 3 +-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/ModelStates/ModelStates/ModelState.php b/app/ModelStates/ModelStates/ModelState.php index 95ec5d5..d14e128 100644 --- a/app/ModelStates/ModelStates/ModelState.php +++ b/app/ModelStates/ModelStates/ModelState.php @@ -22,9 +22,8 @@ public static function defaultState(): ModelState return new StateA(); } - /** @return class-string */ - public static function stateManagerClass(): string + public static function stateManagerClass(): Model { - return StateManager::class; + return new StateManager(); } } diff --git a/app/ModelStates/OtherModelStates/OtherModelState.php b/app/ModelStates/OtherModelStates/OtherModelState.php index 7ce5934..6371d9a 100644 --- a/app/ModelStates/OtherModelStates/OtherModelState.php +++ b/app/ModelStates/OtherModelStates/OtherModelState.php @@ -23,9 +23,8 @@ public static function defaultState(): OtherModelState return new StateX(); } - /** @return class-string */ - public static function stateManagerClass(): string + public static function stateManagerClass(): Model { - return StateManager::class; + return new StateManager(); } } diff --git a/src/ModelStates/HasStateManager.php b/src/ModelStates/HasStateManager.php index e59762e..f2162ac 100644 --- a/src/ModelStates/HasStateManager.php +++ b/src/ModelStates/HasStateManager.php @@ -17,8 +17,7 @@ public static function bootHasStateManager(): void return; } - $stateManagerClass = $self->stateClass()::stateManagerClass(); - $stateManager = new $stateManagerClass(); + $stateManager = $self->stateClass()::stateManagerClass(); assert(in_array(IsStateManager::class, class_uses($stateManager))); $stateManager->setAttribute($stateManager::stateColumnName(), $self->stateClass()::defaultState()::name()); @@ -29,9 +28,9 @@ public static function bootHasStateManager(): void public function getStateAttribute(): State { - $stateManagerClass = $this->stateClass()::stateManagerClass(); - $stateManager = new $stateManagerClass(); + $stateManager = self::stateClass()::stateManagerClass(); assert(in_array(IsStateManager::class, class_uses($stateManager))); + $stateName = $this->stateManager->getAttribute($stateManager::stateColumnName()); assert(is_string($stateName)); diff --git a/src/ModelStates/State.php b/src/ModelStates/State.php index 3bbf52a..c216a5e 100644 --- a/src/ModelStates/State.php +++ b/src/ModelStates/State.php @@ -11,8 +11,7 @@ abstract public static function config(): StateConfig; abstract public static function defaultState(): self; - /** @return class-string */ - abstract public static function stateManagerClass(): string; + abstract public static function stateManagerClass(): Model; public static function name(): string { From 2c9c378a7d7d3f68999194ea0a77cd0291c7442d Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Tue, 26 Nov 2024 12:03:43 +0100 Subject: [PATCH 5/8] drop support for php 8.1 --- .github/workflows/validate.yml | 8 -------- CHANGELOG.md | 1 + composer.json | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index a2b3481..82d2d0b 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -98,16 +98,12 @@ jobs: fail-fast: false matrix: php-version: - - "8.1" - "8.2" - "8.3" laravel-version: - ^9.51 - ^10 - ^11 - exclude: - - php-version: "8.1" - laravel-version: ^11 steps: - uses: actions/checkout@v4 @@ -134,7 +130,6 @@ jobs: fail-fast: false matrix: php-version: - - "8.1" - "8.2" - "8.3" dependencies: @@ -144,9 +139,6 @@ jobs: - ^9.51 - ^10 - ^11 - exclude: - - php-version: "8.1" - laravel-version: ^11 services: mariadb: diff --git a/CHANGELOG.md b/CHANGELOG.md index 3461fd5..153e75e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ See [GitHub releases](https://github.com/mll-lab/laravel-utils/releases). ### Changed - Support multiple `StateManager` classes by configuring the `StateManager`-Model in `StateConfig` and the column name in `StateManager`-Model +- Drop support for php 8.1 ## v8.0.0 diff --git a/composer.json b/composer.json index c425b3f..764f86d 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "source": "https://github.com/mll-lab/laravel-utils" }, "require": { - "php": "^8.1", + "php": "^8.2", "illuminate/support": "^9.51 || ^10 || ^11", "mll-lab/php-utils": "^1.13 || ^2 || ^3 || ^4 || ^5", "mll-lab/str_putcsv": "^1", From e8725476f11ee6113b78c32f04f191b02a1c08b7 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Tue, 26 Nov 2024 15:24:14 +0100 Subject: [PATCH 6/8] avoid unnecessary instantiation --- app/ModelStates/ModelStates/ModelState.php | 5 +-- .../OtherModelStates/OtherModelState.php | 5 +-- src/ModelStates/HasStateManager.php | 40 +++++++++++-------- src/ModelStates/State.php | 3 +- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/app/ModelStates/ModelStates/ModelState.php b/app/ModelStates/ModelStates/ModelState.php index d14e128..dd7b426 100644 --- a/app/ModelStates/ModelStates/ModelState.php +++ b/app/ModelStates/ModelStates/ModelState.php @@ -3,7 +3,6 @@ namespace App\ModelStates\ModelStates; use App\ModelStates\StateManager; -use Illuminate\Database\Eloquent\Model; use MLL\LaravelUtils\ModelStates\State; use MLL\LaravelUtils\ModelStates\StateConfig; @@ -22,8 +21,8 @@ public static function defaultState(): ModelState return new StateA(); } - public static function stateManagerClass(): Model + public static function stateManagerClass(): string { - return new StateManager(); + return StateManager::class; } } diff --git a/app/ModelStates/OtherModelStates/OtherModelState.php b/app/ModelStates/OtherModelStates/OtherModelState.php index 6371d9a..6dd06ab 100644 --- a/app/ModelStates/OtherModelStates/OtherModelState.php +++ b/app/ModelStates/OtherModelStates/OtherModelState.php @@ -5,7 +5,6 @@ use App\ModelStates\StateManager; use App\ModelStates\Transitions\CustomInvalidTransition; use App\ModelStates\Transitions\CustomTransition; -use Illuminate\Database\Eloquent\Model; use MLL\LaravelUtils\ModelStates\State; use MLL\LaravelUtils\ModelStates\StateConfig; @@ -23,8 +22,8 @@ public static function defaultState(): OtherModelState return new StateX(); } - public static function stateManagerClass(): Model + public static function stateManagerClass(): string { - return new StateManager(); + return StateManager::class; } } diff --git a/src/ModelStates/HasStateManager.php b/src/ModelStates/HasStateManager.php index f2162ac..d9c0278 100644 --- a/src/ModelStates/HasStateManager.php +++ b/src/ModelStates/HasStateManager.php @@ -13,13 +13,21 @@ abstract public function stateClass(): string; public static function bootHasStateManager(): void { self::created(function (self $self): void { - if (property_exists($self, 'stateManager') && $self->stateManager !== null) { + if (property_exists($self, 'stateManager') + && isset($self->stateManager) + ) { return; } - $stateManager = $self->stateClass()::stateManagerClass(); - assert(in_array(IsStateManager::class, class_uses($stateManager))); - $stateManager->setAttribute($stateManager::stateColumnName(), $self->stateClass()::defaultState()::name()); + $stateClass = $self->stateClass(); + + $stateManagerClass = $stateClass::stateManagerClass(); + assert(in_array(IsStateManager::class, class_uses($stateManagerClass))); + + $stateManager = new $stateManagerClass(); + + $defaultState = $stateClass::defaultState(); + $stateManager->setAttribute($stateManager::stateColumnName(), $defaultState::name()); $self->stateManager()->save($stateManager); $self->setRelation('stateManager', $stateManager); @@ -28,19 +36,16 @@ public static function bootHasStateManager(): void public function getStateAttribute(): State { - $stateManager = self::stateClass()::stateManagerClass(); - assert(in_array(IsStateManager::class, class_uses($stateManager))); - - $stateName = $this->stateManager->getAttribute($stateManager::stateColumnName()); + $stateName = $this->stateManager->getAttribute($this->stateManager::stateColumnName()); assert(is_string($stateName)); - $stateClasses = $this->stateClassConfig()->possibleStates(); - $stateClass = $stateClasses[$stateName] ?? null; - if ($stateClass === null) { + $possibleStateClasses = $this->stateClassConfig()->possibleStates(); + $currentStateClass = $possibleStateClasses[$stateName] ?? null; + if ($currentStateClass === null) { throw new UnknownStateException("The state {$stateName} of {$this->table} with id {$this->id} is not part of {$this->stateClass()}."); } - return new $stateClass(); + return new $currentStateClass(); } /** @param State|class-string $newState */ @@ -57,15 +62,16 @@ public function setStateAttribute(State|string $newState): void public function stateManager(): MorphOne { - return $this->morphOne( - $this->stateClass()::stateManagerClass(), - 'stateable', - ); + $stateClass = $this->stateClass(); + + return $this->morphOne($stateClass::stateManagerClass(), 'stateable'); } public function stateClassConfig(): StateConfig { - return $this->stateClass()::config(); + $stateClass = $this->stateClass(); + + return $stateClass::config(); } public function stateMachine(): StateMachine diff --git a/src/ModelStates/State.php b/src/ModelStates/State.php index c216a5e..3bbf52a 100644 --- a/src/ModelStates/State.php +++ b/src/ModelStates/State.php @@ -11,7 +11,8 @@ abstract public static function config(): StateConfig; abstract public static function defaultState(): self; - abstract public static function stateManagerClass(): Model; + /** @return class-string */ + abstract public static function stateManagerClass(): string; public static function name(): string { From 04be74bc395b4eb38d023e9206e43c938fe9c686 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Tue, 26 Nov 2024 15:25:11 +0100 Subject: [PATCH 7/8] extract variable --- src/ModelStates/Transition.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ModelStates/Transition.php b/src/ModelStates/Transition.php index 6544d37..2a267ee 100644 --- a/src/ModelStates/Transition.php +++ b/src/ModelStates/Transition.php @@ -48,7 +48,8 @@ public function from(): State /** Can be reused in default state transitions. */ final protected function manage(): void { - $this->model->stateManager->setAttribute($this->model->stateManager::stateColumnName(), $this->to::name()); - $this->model->stateManager->save(); + $stateManager = $this->model->stateManager; + $stateManager->setAttribute($stateManager::stateColumnName(), $this->to::name()); + $stateManager->save(); } } From 3f7ba8c5ea0687edcf016c36d6f5d60c789b88eb Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Tue, 26 Nov 2024 15:49:26 +0100 Subject: [PATCH 8/8] Update CHANGELOG.md Co-authored-by: Benedikt Franke --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b012e8d..7fab17e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,10 @@ See [GitHub releases](https://github.com/mll-lab/laravel-utils/releases). ### Changed - Support multiple `StateManager` classes by configuring the `StateManager`-Model in `StateConfig` and the column name in `StateManager`-Model -- Drop support for php 8.1 + +### Removed + +- Drop support for PHP 8.1 ## v8.0.1