spatie / laravel-activitylog

Log activity inside your Laravel app
https://docs.spatie.be/laravel-activitylog
MIT License
5.36k stars 714 forks source link

Wrong minimal Laravel version in package.json #1217

Closed mspiderv closed 9 months ago

mspiderv commented 1 year ago

Describe the bug Trait Spatie\Activitylog\Traits\LogsActivity on line 371 tries to call getStorableEnumValue method on an Eloquent model. package.json file of the spatie/laravel-activitylog repository requires Laravel version ^8.0 || ^9.0 || ^10.0, but for example in Laravel 9.26.0 there was no getStorableEnumValue method implemented yet. It was added later. For example it is present in Laravel 9.52.15.

To Reproduce Create a new Laravel 9.0.0 app (not newer version!) Then install Spatie Laravel Activity Log. Then reproduce steps here: https://spatie.be/docs/laravel-activitylog/v4/advanced-usage/logging-model-events You will end up with the Call to undefined method App\\Models\\SomeModel::getStorableEnumValue() exception.

Expected behavior It should automatically upgrade my Laravel app to proper version. 9.0.0 is not new enough. You should change the minimal Laravel version in package.json.

Versions (please complete the following information)

Additional context I faced this issue in Laravel 9.26.0. Then I simply upgraded my app with $ composer update. Then my Laravel version raised to 9.52.15 and the problem disappeared. So I suppose that the Laravel developers added getStorableEnumValue somewhere between version 9.26.0 and 9.52.15.

Gummibeer commented 1 year ago

Besides the fact that we are talking about composer.json: go ahead and provide a PR fixing it. In best case with links to the PRs/Commits that introduced that method.

mspiderv commented 1 year ago

Yes, sorry, we talk about composer.json not about package.json as I said earlier. Im not gonna make PR. I just wanted to notice you about the bug. Have a nice day.

sebapastore commented 1 year ago

Hi @mspiderv , I've been looking at this issue and found that the bug was introduced in commit 1ad6f9840ea8166ce2b24b3d0d6da0f8728daef2 and then published in version 4.7.0 of the package. However, I also found that it was fixed in commit a92fde9270b5a26f78e0364bfc91d2ae2fcff249 and released in version 4.7.2 of the package. Therefore, it appears that you might have been using version 4.7.0 or 4.7.1.

@Gummibeer, you may want to take a look at the changes made to the file src\Traits\LogsActivity.php in commit a92fde9270b5a26f78e0364bfc91d2ae2fcff24, where this issue has already been resolved.