Undefined index: id during attachPermission using array
Using attachPermission with object works fine, but using array returns the error "undefined index id".
Role::find(1)->attachPermission([$p1, $p2]); or Role::find(1)->sync([$p1->id, $p2->id]); same result. The error should be on EntrustRoleTrait.php line 87, where you check
if (is_array($permission)) { $permission = $permission['id']; }
but in that case $permission is an array with no id property in it, isn't?!
you have to add a 's' to attachPermission (= attachPermissions) if you use an array
@yopbot could you be more specific where does the = goes however i tried the other way ```
$permissions = $request->input('permissions'); //$role->attachPermission($permissions); doesn't work $role->perms($role->id)->sync($permissions); //This work fine for me
Got it now! @yopbot there are two methods one for attaching one permission and the other for attaching multiple permissions.