title: Laravel 5: route-model-binding not recognizing object
body: <p>I have a <code>search()</code> method in <code>SubredditController</code></p>
  
  <pre><code>public function search(Request $request, Subreddit $subreddit)
  {
      $query = $request-&gt;input('search');
      $subreddit = Subreddit::with('posts.votes')-&gt;with('moderators.user')-&gt;where('id', 24)-&gt;first();
      $posts = $subreddit-&gt;posts()-&gt;where('title', 'LIKE', '%' . $query . '%')-&gt;get();
      $isModerator = $subreddit-&gt;moderators()-&gt;where('user_id', Auth::id())-&gt;exists();
      $modList = Moderator::where('subreddit_id', '=', $subreddit-&gt;id)-&gt;get();
  
      return view('subreddit.search', compact('query', 'subreddit', 'posts', 'isModerator', 'modList'));
  }
  </code></pre>
  
  <p>As you can see <code>$subreddit</code> is getting all posts from subreddit ID 24 and the query works.</p>
  
  <p>But when I replace 24 with <code>$subreddit-&gt;id</code> the query fails and gives null.</p>
  
  <p><strong>EDIT:</strong> Looks like it works on <code>$modList</code> because I have hardcoded it <code>24</code> in the first variable <code>$subreddit</code> but that still doesn't answer why <code>$subreddit-&gt;id</code> is inaccessible when it works fine on all other methods of the same controller</p>
  
  <p><strong>EDIT 2:</strong> I have also tried changing the <code>search</code> route to accept a parameter, like this <code>Route::post('search/{subreddit}')</code> but that gives the error <code>NotFoundHttpException</code> and the URL redirects to <code>localhost/reddit/public/search/%7Bsubreddit%7D</code> it's not recognizing any parameter.</p>
  
  <p><strong>EDIT 3:</strong> if I change the <code>search</code> route to <code>Route::post('subreddit/{id}/search', ...)</code> I get no errors, but <code>$subreddit-&gt;id</code> remains inaccessible and the URL points to <code>subreddit/%7Bid%7D/search</code> (with %7B characters)</p>
  
  <p>These are my bindings</p>
  
  <pre><code>$router-&gt;model('subreddit', 'App\Subreddit');
  $router-&gt;model('posts', 'App\Post');
  $router-&gt;model('moderators', 'App\Moderator');
  </code></pre>
  
  <p>My Routes</p>
  
  <pre><code>Route::resource('subreddit', 'SubredditController');
  
  Route::resource('subreddit.moderators', 'ModeratorsController');
  
  Route::get('mysubreddits', [
      'as' =&gt; 'mysubreddits',
      'uses' =&gt; 'SubredditController@mySubreddits'
  ]);
  
  Route::post('search', ['as' =&gt; 'search', 'uses' =&gt; 'SubredditController@search']);
  
  Route::resource('posts', 'PostsController');
  Route::resource('votes', 'VotesController');
  Route::resource('profile', 'ProfilesController');
  </code></pre>
  
  <p>The view (which is a partial) from where I'm sending the search request</p>
  
  <pre><code>&lt;h4&gt;Search {{ $subreddit-&gt;name }}&lt;/h4&gt;
  {!! Form::open(['action' =&gt; 'SubredditController@search']) !!}
  &lt;div id="custom-search-input"&gt;
      &lt;div class="input-group col-md-12"&gt;
          &lt;input type="text" name="search" class="search-query form-control" placeholder="Search" /&gt;
              &lt;span class="input-group-btn"&gt;
                  &lt;button class="btn btn-danger" type="submit"&gt;
                      &lt;span class=" glyphicon glyphicon-search"&gt;&lt;/span&gt;
                  &lt;/button&gt;
              &lt;/span&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  {!! Form::close() !!}
  </code></pre>