Support the ongoing development of Laravel.io →
posted 2 weeks ago
Last updated by @tvbeek 1 week ago.
1
moderator

Hello @titia-sudo

I think you need to change $user->roles()->attach($request->role_id); to $user->roles()->attach($request->role); because in your request you call it role and not role_id.

ps. I have updated your post to get clear codeblocks.

0

Sign in to participate in this thread!

JetBrains

Your banner here too?

OFT titia-sudo Joined 18 Sep 2023

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 Laravel.io - All rights reserved.