what i want to achieve is that inside the DB query i insert all the records in one go so that the query doesn't run many times. the following code doesn't allow me to use the for loop inside the array. kindly help.
if($user=="MasterDealer")
{
if($request['accessibleTodealers']!='' || $request['accessibleTodealers']!=null)
{
$memberships=explode(",",$request['accessibleTodealers']);
$membe = array();
$now = Carbon::now();
DB::table('accessible_membership_logs')->insert([
array(
for ($i=0; $i <count($memberships) ; $i++){
array(
['membership_id']=$memberships[$i],
['masterdealer_id']=$dealer,
['dealer_id'] = null,
['user'] = 'masterdealer',
['operation'] = 'Accessible',
['admin_id'] = $data['id'],
['created_at'] = $now->format('Y-m-d H:i:s'),
['updated_at'] = $now->format('Y-m-d H:i:s')
)}
)
]);
Alert::message("","Changes Updated.!","success");
return redirect()->intended('/admin/masterDealerDetail/'.$dealer);
}
}