SHARE
TWEET

controller

a guest May 19th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.    $data['tagUser']        = $request->input('user_id'); // array
  2.         $memberUserID           = $request->input('member_user_id');
  3.         $periodStartDate        = $request->input('period_start_date');
  4.         $periodEndDate          = $request->input('period_end_date');
  5.         $data['title']          = $request->input('title'); // array
  6.         $data['playback_count'] = $request->input('playback_count'); // array
  7.         $data['id_song']        = $request->input('id_song'); // array
  8.         $clientCategory         = $request->input('client_category_id');
  9.         $memberTypeID           = $request->input('member_type_id');
  10.         $excelID                = $request->input('excel_upload_id');
  11.         $action                 = $request->input('action');
  12.    if(is_array($data['tagUser'])){
  13.             for($i=0; $i<count($data['tagUser']); $i++){
  14.                 $ut[] = UserTags::where('tag',$data['tagUser'][$i])->first()->toArray();
  15.                 $check[] = Playback::where('user_id',$ut[$i]['user_id'])->where('title',$data['title'][$i])->first();
  16.             }
  17.         }
  18.        
  19.         if(is_array($data['tagUser'])){
  20.             for($i=0; $i<count($data['tagUser']); $i++){
  21.                 if($check[$i]==null){
  22.                     $playback = new Playback;
  23.                 }
  24.                 else{
  25.                     $playback = Playback::find($check[$i]['id']);
  26.                 }
  27.  
  28.                         $playback->client_category_id = $clientCategory;
  29.                         $playback->user_id            = $ut[$i]['user_id'];
  30.                         $playback->period_start_date  = $periodStartDate;
  31.                         $playback->period_end_date    = $periodEndDate;
  32.                         $playback->member_type_id     = $memberTypeID;
  33.                         $playback->id_song            = $data['id_song'][$i];
  34.                         $playback->member_user_id     = $memberUserID;
  35.                         $playback->title              = $data['title'][$i];
  36.                         $playback->excel_upload_id    = $excelID;
  37.                         $playback->playback_count     = $data['playback_count'][$i];
  38.                         $playback->save();            
  39.             }
  40.         }
  41.                     if($action == 'insert'){
  42.                 return redirect()->route('playback.index')->with('success', 'Upload playback berhasil!');
  43.             }else{
  44.                 return redirect()->route('playback.index')->with('success', 'Update playback berhasil!');
  45.             }
  46.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top