Level 29
Try dd, maybe the permissions is not sent.
dd($data);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have this tables:
users
permissions
roles
role_user
permission_user
permission_role
Giving permissions to roles on my system works well.
I Want When set a role for a user,Automatically apply permissions to that user.but it gives the error
Undefined array key "permissions"
User Controller
public function update(Request $request,User $user)
{
$data = $request->all();
$user->update($data);
if ($user) {
$user->roles()->sync($data['roles']);
$user->permissions()->sync($data['permissions']);
return redirect()->action('Admin\UsersController@index')->with([
'message' => 'User Successfully Updated',
'messageTitle' => 'Update User'
]);
}
}
Please or to participate in this conversation.