I am trying to get data from one form and save it to another db table with modifications. But, I am getting error:
trying to get property of non-object
on the last line from the given block of codes.
$ply->team_name = $request->get('team_name');
$team_name=$ply->team_name;
$team=Team::find($team_name);
$team->balance=$team->balance-$ply->sold_amount;
$team=Team::find($team_name);find is equivalent to where id = $var so it will return null to fix it try this$team=Team::where('name', $team_name)->get();