public function update(Request $request, $year, $month, $day) { $date = $this->createDate($year, $month, $day); $file = $request->file('photo'); if (is_null($file)) { abort(400); } $photo = new Photo($date); $image = Image::make($file); $photo->save($image); return response(json_encode($photo->toArray()), 201)->header('Content-Type', 'application/json'); }