user3721008
user3721008

Reputation: 103

laravel doesn't update data until I refresh the set page

I new in laravel and I'm doing simple edit form that's the code

  public function updateSinglePR(points_redemption $pr,Request $request)
 {
  echo $pr->redemotion_mount.'<br>';
  echo $pr->points_mount.'<br>';
  echo $pr->id;
  $pr->update($request->all());
  //return redirect('/setPointtoRedemption');
 }

so when I send the new data I goes to the with old values and i tried to stop returning and get the values , and if refreshed the page that update the data it set the data and update it I think it's something in the session but i can't know why or how to fix

thanks

Upvotes: 0

Views: 965

Answers (1)

Arthur Samarcos
Arthur Samarcos

Reputation: 3299

Ok, let's review your code:

  public function updateSinglePR(points_redemption $pr,Request $request)

This function will pass to you variables $pr and $request.

$pr is your entity as it is now, without modifications.

$request have your Request object that includes all the information you have provided in your form.

  echo $pr->redemotion_mount.'<br>';

echo $pr->points_mount.'
'; echo $pr->id;

This will echo $pr information (not yet updated, of course) to your http response.

  $pr->update($request->all());

Will finally update your table with new data from your form.

If you reload the page it will load a new "$pr" model from the database (now updated).


Update for your comment:

Try changing the order of the arguments:

public function updateSinglePR(Request $request, points_redemption $pr)

Upvotes: 1

Related Questions