/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request, Group $group) { $action = new Action(); $action->name = $request->input('name'); $action->body = $request->input('body'); $action->start = Carbon::createFromFormat('Y-m-d H:i', $request->input('start')); $action->stop = Carbon::createFromFormat('Y-m-d H:i', $request->input('stop')); if ($request->get('location')) { $action->location = $request->input('location'); if (!$action->geocode()) { flash()->error(trans('messages.address_cannot_be_geocoded')); } else { flash()->info(trans('messages.ressource_geocoded_successfully')); } } $action->user()->associate($request->user()); $action->group()->associate($group); if ($action->isInvalid()) { // Oops. return redirect()->action('ActionController@create', $group_id)->withErrors($action->getErrors())->withInput(); } else { $action->save(); return redirect()->action('ActionController@index', [$group->id]); } }