passing the role name isn't eloquent .
you can pass an array of id's passing an array or objects with internally takes all the id's and passes again,
you can also pass a key value array of ids and their pivot data too
Are there any special functions or methods I should know about that help me get the ID by using the role name?
$role = App\Role::where('name', 'admin')->first();
$user->roles()->sync($role->id)
LaurentMeganck said:
$role = App\Role::where('name', 'admin')->first(); $user->roles()->sync($role->id)
Thanks. I figured that could be done, but was wondering if there was a one liner solution.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community