How to loop through multiple foreach loops and insert data into the database
Good morning bros, how are you?
i am having an issue with this loop
$users = User::all();
foreach($users as $user)
{
foreach($data->toArray() as $dataRows)
{
if($user->admin ==0)
{
$Data[]=
[
'user_id' => $user->id,
'avatar' => 'avatar.png',
'about' => $dataRows['description']
];
}
}
}
profile::insert($Data);
It loops through each user and assigns all the dataRows to each user. please help
from Laravel Questions and Answers https://laravelquestions.com/php/how-to-loop-through-multiple-foreach-loops-and-insert-data-into-the-database/
via Lzo Media
No comments:
Post a Comment