Advertisement
vandyahmad24

Untitled

Jan 20th, 2020
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.61 KB | None | 0 0
  1. $data = DB::table('user.user_details')->where('vendor_id',$request->id)->orderBy('created_at','asc')->orderBy('client_id','asc')->get();
  2.         // first i try get data before changing
  3.         $vendor_array=[];
  4.         foreach ($data as $key => $value){
  5.                 array_push($vendor_array,$value->vendor_profile_value);
  6.         }
  7.         // dd($vendor_array);
  8.         <!-- then I try to enter the data that I send into the array -->
  9.         $masuk=[];
  10.         foreach($request->name as $item=>$value){
  11.             $vendor_detail=array(
  12.                
  13.                 'name' =>$request->name[$item],
  14.                 'categori'=>$request->category[$item],
  15.                 'duration'=>$request->duration[$item],
  16.                 'discount_status'=>$request->discount_status[$item],
  17.                 'percentage' => $request->percentage[$item]
  18.             );
  19.             array_push($masuk,$vendor_detail);
  20.         }
  21.         $masuk=[];
  22.         foreach($arrays as $key => $value){
  23.             foreach($value as $key2 => $value2){
  24.                 array_push($masuk,$value2);
  25.             }
  26.         }
  27.         <!-- then I tried updating it with the query builder by getting the previous data, but it didn't work  -->
  28.        
  29.        // dd($masuk);
  30.        foreach($vendor_array as $key => $value){
  31.           foreach($masuk as $masuk_key => $masuk_value){
  32.             $x = DB::table('koinpintar.vendor_details')->where([['vendor_id',$request->vendor_id],['vendor_profile_value',$value]])->update([
  33.                    'vendor_profile_value' => $masuk_value
  34.              ]);
  35.              dd($x);
  36.           }
  37.        }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement