public function update(Request $request, Blog $blog) { $insert = $blog->fill($request->input())->save(); $image = \Input::get('image'); if ($image != '') { $imagename = 'blog-' . rand(11111, 99999) . '-gudperna.png'; $image = str_replace(' ', '+', $image); list($type, $image) = explode(';', $image); list(, $image) = explode(',', $image); $image = base64_decode($image); file_put_contents('upload/img/' . $imagename, $image); $blog->image = $imagename; $blog->save(); } if ($insert) { return 0; } else { return 1; } }