public function update($userType, $id, Request $req) { $temp = null; if ($userType == 'admin') { Admin::findOrNew($id)->update($req->all()); $temp = Admin::findOrNew($id); } elseif ($userType == 'founder') { Founder::findOrNew($id)->update($req->all()); $temp = Founder::findOrNew($id); } elseif ($userType == 'investor') { Investor::findOrNew($id)->update($req->all()); $temp = Investor::findOrNew($id); } elseif ($userType == 'campaign') { Campaign::findOrNew($id)->update($req->all()); $temp = Campaign::findOrNew($id); } flash()->success($userType . ' Updated'); return view('admin.edit', [$userType => $temp, 'userType' => $this->getUserType($userType)]); }