public function save(Request $request) { $team = Team::firstOrNew(['account_id' => $request->account]); $team->account_id = $request->account; $team->theData = json_encode($request->data); $team->save(); return $team; }
public function saveTeam(Request $request) { if ($request->saved_id > 0) { $team = Team::where('id', $request->saved_id)->last(); $team->account_id = $request->account; $team->theData = json_encode($request->data); } else { $team = Team::firstOrNew(['account_id' => $request->account]); $team->account_id = $request->account; $team->theData = json_encode($request->data); } $team->save(); return $request->data; }