I created 3 basic roles to test with...
Role::create(['guard_name' => 'super-admin', 'name' => 'superadmin']);
Role::create(['guard_name' => 'admin', 'name' => 'admin']);
Role::create(['guard_name' => 'user', 'name' => 'user']);
I assigned the role during a debug test...
auth()->loginUsingId(1);
auth()->user()->assignRole('admin');
// Error retrieved...
RoleDoesNotExist in RoleDoesNotExist.php line 11:
There is no role named admin.
There is clearly a role named 'admin' and the 'guard-name' is also 'admin'
Why can't I find it?

Additional Comment: I have already gone through and performed the clear cache as it stated as well... just in case :D
From what I can gather...
it's using the guard 'web' in my whoops debugger:
Role::findByName('admin', 'web')
oh, I think I see what the reasoning is for this... testing in a second and I will delete if I figured it out :D
@SeoRoman Have you resolved your issue?
@SeoRoman What have you set as your guard_name? I was facing the same issue until I set it as 'web'. I believe it's beacuse that is the default guard set on 'auth.php'
@ChiefScript Check latest comments in issue #276
I had the same issue and have figured out the solution and i.e.
First add "protected $guard_name = 'api';" in User.php (Model file).

Then, Change your field guard_name to "api" in your roles table as shown in screenshot below.

Enjoy Coding :)
Feel Free to Reply for any issues regarding this.
@sushantDev Thank you soo much it's working...(after searching many googling ;-) )
I had the same issue and have figured out the solution and i.e.
First add "protected $guard_name = 'api';" in User.php (Model file).
Then, Change your field guard_name to "api" in your roles table as shown in screenshot below.
Enjoy Coding :)
Feel Free to Reply for any issues regarding this.
I love you
I had the same issue and have figured out the solution and i.e.
First add "protected $guard_name = 'api';" in User.php (Model file).
Then, Change your field guard_name to "api" in your roles table as shown in screenshot below.
Enjoy Coding :)
Feel Free to Reply for any issues regarding this.
Hi.. I got there is no permission named some permission for guard `api, any idea?
Most helpful comment
I had the same issue and have figured out the solution and i.e.
First add "protected $guard_name = 'api';" in User.php (Model file).

Then, Change your field guard_name to "api" in your roles table as shown in screenshot below.

Enjoy Coding :)
Feel Free to Reply for any issues regarding this.