1$history = [];
2foreach($array as $value){
3 $array = [
4 'value' => $value,
5 'status_id' => 2
6 ];
7 array_push($history, $array);
8}
1 if(!empty($value))
2 {
3 foreach ($value as $v)
4 {
5 $insert[] = ['name' => $v['name'], 'email' => $v['email'],'company_name' => $v['company_name'],'company_id' => $v['company_id'], 'emp_id' => $v['emp_id']];
6 $role_id= $v['role_id'];
7 $name=$v['name'];
8 $email=$v['email'];
9 $emails[]=$v['email'];
10 $emp_id=$v['emp_id'];
11 $data = array( 'name' => $name,'email' => $email , 'emp_id' => $emp_id);
12 $roles[]= $v['role_id'];
13
14 }
15 }
16 }
17
18 if(!empty($insert))
19 {
20 $inserted=User::insert($insert);
21 if($inserted)
22 {
23 $email_select=User::select('id')->whereIn('email',$emails)->where('company_id',Auth::user()->company_id)->orderBy('id','Asc')->get();
24 foreach ($email_select as $key => $idget)
25 {
26 $getid[]=$idget->id;
27 }
28 }
29 $datas[]=['user_id' => $getid , 'role_id' => $roles];
30 $insert_role=DB::table('role_user')->insert($datas) ;
31