this function is not working the way i want , when i call the route the record from redeem table id deleted but the new record in note tabel is not

Viewed 15

how i can edit this function to make it work now this myfunction

     public function done($redeem_id,$uid ,$admin_id)
       {
      $redeem =Redeem::where('redeem_id',"=", $redeem_id)->first();
      $user =User::where('id',"=", $uid)->first();       
      $admin =User::where('id',"=", $admin_id)->first();
      $note= new Note();
      $note->user_note='congrats redeem is completed successfully!';
       $note->admin_note= $admin->name.'has approved to redeem '.$redeem->redeem_points.' and transfare money by '.$redeem->method.'to user' .$user->name . 'with email:'.$user->name.'and id:'. $user->name  ;
       $note->user_email=$user->email;
       $note->user_name=$user->name;
      $note->points=$redeem->points;
      $note->note_user=$redeem->redeem_user;
      $amount=$redeem->points;
      $banned=$user->banned_points;
      $redeemd=$user->redeemd_points;
      $user->banned_points=$banned-$amount;
      $user->redeemd_points=$redeemd+$amount;
      $user->save();
      $redeem->delete();
       return redirect()->back();
            }

and this is the rout for the function

     Route::post('/done/{rid}/{uid}/{aid}',[ UserController::class,'done'])->name('users.done');

in veiw

    <td><a href="{{url('/done/'.$redeem->redeem_id.'/'.$redeem->redeem_user.'/'. Auth::user()->id)}}"><button class="uk-button uk-button-default"style="color:green;" type="button">Done</button></td>
0 Answers
Related