title: Laravel4: Call to a member function update() on a non-object
body: <p>Following are my codes:</p>
  
  <p><strong>Model:</strong></p>
  
  <pre><code>class Slide extends \Eloquent {
  
      // Add your validation rules here
      public static $rules = [
          'title' =&gt; 'required|between:3,100',
          'image' =&gt; 'required',
          'url' =&gt; 'url',
          'active' =&gt; 'integer'
      ];
  
      // Don't forget to fill this array
      protected $fillable = ['title', 'image', 'url', 'active'];
  
  }
  </code></pre>
  
  <p><strong>Controller Update Method:</strong></p>
  
  <pre><code>public function update($id)
  {
      $slide = Slide::find($id);
  
      $validator = Validator::make($data = Input::all(), Slide::$rules);
  
      if ($validator-&gt;fails())
      {
          return Redirect::back()-&gt;withErrors($validator)-&gt;withInput();
      }
  
      $slide-&gt;update($data);
  
      return Redirect::route('admin.slides.index')
              -&gt;with('message', 'Slide has been updated.')
              -&gt;with('message-type', 'alert-success');
  }
  </code></pre>
  
  <p><strong>Route:</strong></p>
  
  <pre><code>Route::group(array('prefix' =&gt; 'admin'), function() {
      # Slides Management
      Route::resource('slides', 'AdminSlidesController', array('except' =&gt; array('show')));
  });
  </code></pre>
  
  <p><strong>Form in View:</strong></p>
  
  <pre><code>{{ Form::model($slide, array('route' =&gt; 'admin.slides.update', $slide-&gt;id, 'method' =&gt; 'put')) }}
      @include('admin/slides/partials/form')
  {{ Form::close() }}
  </code></pre>
  
  <p>Partial Form is simple form, not sure if I need to share it here or not. Let me know.</p>
  
  <p><strong>Error:</strong></p>
  
  <p>Edit page loads perfectly and populates data from db, but when I submit the edit form, I get following error:</p>
  
  <blockquote>
    <p>Call to a member function update() on a non-object </p>
  </blockquote>
  
  <p>The following line seems to be creating problems:</p>
  
  <blockquote>
    <p>$slide->update($data);</p>
  </blockquote>
  
  <p>I have searched over the internet for solution but nothing is working. Have tried composer dump_autoload, even tried doing everything from scratch in a new project, still same issue. :(</p>
  
  <p>Help please!!</p>
  
  <p>---- Edit ----</p>
  
  <p>Just quickly tried following:</p>
  
  <pre><code>public function update($id)
  {
      $slide = Slide::find($id);
      $slide-&gt;title = Input::get('title');
      $slide-&gt;save();
  
      return Redirect::route('admin.slides.index')
              -&gt;with('message', 'Slide has been updated.')
              -&gt;with('message-type', 'alert-success');
  }
  </code></pre>
  
  <p><strong>Now the error:</strong></p>
  
  <blockquote>
    <p>Creating default object from empty value </p>
  </blockquote>
  
  <h2><strong>----- Solution: -----</strong></h2>
  
  <p>The problem was with my form as suggested by @lukasgeiter 
  I changed my form to following at it worked like a charm:</p>
  
  <pre><code>{{ Form::model($slide, array('route' =&gt; array('admin.slides.update', $slide-&gt;id), 'method' =&gt; 'put')) }}
  </code></pre>