Laravel 8 Menyimpan Kotak Centang Dinamis Array Nilai Integer

if (isset($_POST['roleSubmit'])){
    DB::table('role_users')->where('user_id', $request->get('id', $id))->delete();


    $userRole = $request->input('rolename');
    foreach($userRole as $role){
        DB::table('role_users')->insert(
           array(
             'user_id' => $id,
             'role_id' => $role
           )
        );
    }
    return redirect()->back();
}
Selfish Skipper