multicaret / laravel-acquaintances

This package gives Eloquent models the ability to manage friendships (with groups), followships along with Likes, favorites..etc.
https://laravel-news.com/manage-friendships-likes-and-more-with-the-acquaintances-laravel-package
MIT License
808 stars 72 forks source link

Error: Class "App\User" not found #64

Closed jupiter80 closed 3 years ago

jupiter80 commented 3 years ago

Performed a composer update to a running project and have isolated the issue to the "Like" components. Prior to this, the project worked perfectly.

Receive Error Class "App\User" not found...

Example call that resolves in this error: $nugget->isLikedBy(auth()->user()) or $nugget->likersCountReadable()

Stack Trace: [2021-07-11 20:26:53] local.ERROR: Class "App\User" not found (View: /var/www/html/resources/views/nugget/nuggets.blade.php) {"view":{"view":"/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php","data":[]},"userId":1,"exception":"[object] (Facade\Ignition\Exceptions\ViewException(code: 0): Class \"App\User\" not found (View: /var/www/html/resources/views/nugget/nuggets.blade.php) at /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php:745) [stacktrace]

0 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php(549): Illuminate\Database\Eloquent\Model->newRelatedInstance()

1 /var/www/html/vendor/multicaret/laravel-acquaintances/src/Traits/CanBeLiked.php(33): Illuminate\Database\Eloquent\Model->morphToMany()

2 /var/www/html/vendor/multicaret/laravel-acquaintances/src/Interaction.php(69): App\Models\Nugget->likers()

3 /var/www/html/vendor/multicaret/laravel-acquaintances/src/Traits/CanBeLiked.php(22): Multicaret\Acquaintances\Interaction::isRelationExists()

4 /var/www/html/resources/views/nugget/nuggets.blade.php(122): App\Models\Nugget->isLikedBy()

Versions

PHP Version: 8.0.1 app()->version() returns: 8.49.2 Composer.lock: "name": "multicaret/laravel-acquaintances", "version": "v3.5.4",

It looks like the change may be related to the June 28th namespace update. Any help would be greatly appreciated!

francoism90 commented 3 years ago

You need to update/(re)publish config/acquaintances.php :

'model_namespace' => 'App\Models',
jupiter80 commented 3 years ago

Thank you. After I removed the prior published config/acquaintances.php file and reran php artisan vendor:publish --provider="Multicaret\Acquaintances\AcquaintancesServiceProvider", it works now. Thank you for the quick answer!