Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel 8 storing dynamic checkbox integer value array

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();
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #storing #dynamic #checkbox #integer #array
ADD COMMENT
Topic
Name
3+5 =