Getting images to update

Getting images to update

Yesterday I managed to save my images to the database, but now when I try to edit the image and then save it, it doesn't save. I'm not sure where I'm going wrong. All the content saves except for the image.

Here is the test.js
  1. $(document).ready(function(){


  2.     $(".add-form").submit(function(event){
  3.         $(this).find(".testing").each(function(){
  4.             var image = [];
  5.             $(this).parent().find(".ajax-file-upload-statusbar").each(function() {
  6.                 image.push($.trim($(this).find(".ajax-file-upload-filename").html()));
  7.             });
  8.             $(this).parent().find(".img-hidden").val(JSON.stringify(image));
  9.         });

  10.         $.ajax({
  11.             type: 'POST',
  12.             url: $(this).attr('action'),
  13.             data: $(this).serialize(),
  14.             dataType: 'json',
  15.             encode : true,
  16.         });
  17.     });
  18. });
I'm putting my laravel code as well just in case it helps
Here is my edit.blade.php
  1. @extends('templates::admin')
  2. @section('content')

  3.     {{ HTML::script('js/test.js') }}
  4.     <script type="text/javascript">
  5.         var settings = {
  6.                     url: '{{ asset("upload/upload.php") }}',
  7.                     dragDrop:true,
  8.                     multiple : false,
  9.                     showFileCounter:false,
  10.                     showDone: false,
  11.                     fileName: "myfile",
  12.                     allowedTypes:"jpg,png,gif,pdf", 
  13.                     returnType:"json",
  14.                     showDelete:true,
  15.                 }
  16.     </script>

  17.     <div class="row">
  18.         <div class="col-lg-12">
  19.             {{ Form::model($galleries, array('method' => 'PATCH', 'route' => array('admin.gallery.update', $galleries->id), 'class' => 'add-form')) }}
  20.         <div class="form">
  21.             <div>
  22.                 {{ Form::label('title', 'Title') }}
  23.             </div>
  24.             <div>
  25.                 {{ Form::text('title', $galleries->title, array('id' => 'title', 'class' => 'form-control')) }}
  26.             </div>
  27.             <div>
  28.                 {{ Form::label('content', 'Content') }}
  29.             </div>
  30.             <div>
  31.                 {{ Form::textarea('content', $galleries->content) }}
  32.             </div>

  33.             <div id="fileuploader" class="testing">Upload</div>
  34.             {{ getImages($galleries->image) }}
  35.             <script>
  36.                 var uploadObj = $("#fileuploader").uploadFile(settings);
  37.             </script>
  38.             {{ Form::hidden('image', '', array('id' => 'img-add', 'class' => 'img-hidden')) }}

  39.             <div>
  40.                 {{ Form::submit('Submit', array('class' => 'btn btn-default', 'role' => 'button')) }}
  41.             </div>
  42.         </div>
  43.     {{ Form::open() }}

  44.     @if($errors->any())
  45.         <ul>
  46.             {{ implode('', $errors->all('<li class="error">:message</li>')) }}
  47.         </ul>
  48.     @endif
  49.         </div>
  50.     </div>
  51. @stop
and this is the update function in my galleryController
  1. public function update($id)
  2.     {
  3.         $input = Input::all();
  4.         $validation = Validator::make($input, Gallery::$rules);

  5.         if($validation->fails()){
  6.             return Redirect::route('admin.gallery.edit')
  7.                 ->withInput()
  8.                 ->withErrors($validation)
  9.                 ->with('message', 'There were validation errors');
  10.         }

  11.         if($validation->passes()){
  12.             $galleries = Gallery::FindOrFail($id);

  13.             $galleries->update($input);
  14.             return Redirect::route('admin.gallery.index', $id);
  15.         }
  16.     }