my name is andy and i'm new to Laravel, I would like to ask how to store my user id into the new table which table name ( company_policy_users ) by using looping method ? Can anyone help me out ? Thank you so much Here is my controller coding
foreach ($array as $selectedUser){
$policyUser = new $policyUser([
'policy' => $request->get('id'),
'user_id' => $selectedUser,
'read' => 0
]);
$policyUser->save();
My database name = ( company_policy ) with table name - ( company_policy_users ) : The column we have inside the ( company_policy_users ) table 1. id = (bigint) 2. user_id = (int) 3. policy_id = (int) 4. read_by = ( Boolean ) 5. date_read = (datetime)