mostafamaklad / laravel-permission-mongodb

Associate users with roles and permissions using Laravel and MongoDB
https://maklad.dev
MIT License
112 stars 66 forks source link

Return value of Maklad\Permission\Models\Role::permissions() must be an instance of Jenssegers\Mongodb\Relations\BelongsToMany, instance of Illuminate\Database\Eloquent\Relations\BelongsToMany returned #122

Closed ovis-it closed 3 years ago

ovis-it commented 3 years ago

Hi there, i install a fresh copy of laravel 8 for coreUI laravel-template-Vue. In this template some seeder files are in. The Main tings works, but the permissionmodel not. if i try to use givePermissonsTo i get this error. I don't know why.

>  TypeError 
> 
>   Return value of Maklad\Permission\Models\Role::permissions() must be an instance of Jenssegers\Mongodb\Relations\BelongsToMany, instance of Illuminate\Database\Eloquent\Relations\BelongsToMany returned
> 
>   at vendor/mostafamaklad/laravel-permission-mongodb/src/Traits/HasPermissions.php:49
>      45▕      * @return BelongsToMany
>      46▕      */
>      47▕     public function permissions(): BelongsToMany
>      48▕     {
>   ➜  49▕         return $this->belongsToMany(config('permission.models.permission'));
>      50▕     }
>      51▕ 
>      52▕     /**
>      53▕      * Grant the given permission(s) to a role.
> 
>       +1 vendor frames 
>   2   database/seeders/MenusTableSeeder.php:105
>       Maklad\Permission\Models\Role::givePermissionTo()
> 
>   3   database/seeders/MenusTableSeeder.php:187
>       Database\Seeders\MenusTableSeeder::insertLink()

THX for help

mostafamaklad commented 3 years ago

Please make sure that the User Model is extending \Jenssegers\Mongodb\Eloquent\Model