/** * Store a newly created resource in storage. * @param type Teams $team * @param type TeamRequest $request * @return type Response */ public function store(Teams $team, TeamRequest $request) { try { /* Check whether function success or not */ if ($team->fill($request->input())->save() == true) { /* redirect to Index page with Success Message */ return redirect('teams')->with('success', 'Teams Created Successfully'); } else { /* redirect to Index page with Fails Message */ return redirect('teams')->with('fails', 'Teams can not Create'); } } catch (Exception $e) { /* redirect to Index page with Fails Message */ return redirect('teams')->with('fails', 'Teams can not Create'); } }
/** * Store a newly created resource in storage. * @param type Teams $team * @param type TeamRequest $request * @return type Response */ public function store(Teams $team, TeamRequest $request) { if ($request->team_lead) { $team_lead = $request->team_lead; } else { $team_lead = null; } $team->team_lead = $team_lead; try { /* Check whether function success or not */ $team->fill($request->except('team_lead'))->save(); /* redirect to Index page with Success Message */ return redirect('teams')->with('success', 'Teams Created Successfully'); } catch (Exception $e) { /* redirect to Index page with Fails Message */ return redirect('teams')->with('fails', 'Teams can not Create' . '<li>' . $e->errorInfo[2] . '</li>'); } }