spatie/laravel-permission

assignRole > getModel() > null

jackjackde opened this issue · 0 comments

Describe the bug
I am currently struggling with role assigning to a User. In src/Traits/HasRoles.php at line 151, the getModel method return null instead of the model. I would like to know, where the model is set?
I found this method in different places in multiple modules, so i guess it's something "eloquent model" do or magic.

Screenshot 2024-02-17 at 09 05 52

Versions:
spatie/laravel-permission package version: 6.3.0
laravel/framework package: v10.43.0
PHP version: 8.3.2

Database version: MySQL 8.2.0

To Reproduce
Steps to reproduce the behavior:

// create demo users
$user = \App\Models\User::factory()->create([
    'name' => 'Example User',
    'email' => 'test@example.com',
]);
$user->assignRole($role1);