/** * Update the specified resource in storage. * * @param int $id * * @return Response */ public function update(Request $request, Group $group, Action $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 ($action->location != $request->input('location')) { // we need to update user address and geocode it $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()); // we use revisionable to manage who changed what, so we keep the original author if ($action->isInvalid()) { // Oops. return redirect()->action('ActionController@create', $group_id)->withErrors($action->getErrors())->withInput(); } $action->save(); return redirect()->action('ActionController@show', [$action->group->id, $action->id]); }