Ejemplo n.º 1
0
 public function actionUpdate($id, Requests\UpdatePhotoRequest $request)
 {
     // Set logged in user to a variable.
     $authUser = Auth::user();
     // Find photo in database.
     $photo = Photo::where('user_id', '=', $authUser->id)->findOrFail($id);
     // Update photo in database.
     $photo->update($request->all());
     // Sync tags to photo.
     $tags = $request->input('tags');
     if (!is_array($tags)) {
         $tags = [];
     }
     $tagSync = $this->checkTags($tags);
     $photo->tags()->sync($tagSync);
     // Redirect with flash message.
     \Session::flash('flash_message', 'You have successfully updated a photo.');
     return redirect('/photos/' . $photo->id);
 }