Laravel Route model binding (slug) only works for show method?
<p>I have <em>Article</em> model and <em>articles</em> table in the database. Each article can be shown using Laravel's standard URI structure: <code>www.example.com/articles/5</code> (where <code>5</code> is the article <code>id</code>). Each article has a <em>slug</em> field (<em>slug</em> column in the articles table), so with <strong>Route Model Binding</strong> I use <code>slug</code> instead of <code>id</code>:</p>

<p><strong>RouteServiceProvider.php:</strong></p>

<pre><code>public function boot(Router $router)
{
    parent::boot($router);

    \Route::bind('articles', function($slug) {
        return \App\Article::where('slug', $slug)-&gt;firstOrFail();
    });
}
</code></pre>

<p>In routes.php I have:</p>

<pre><code>Route::resource('articles', 'ArticleController');
</code></pre>

<p>and now articles can be accessed with URLs like: <code>www.example.com/some_slug</code> .</p>

<p>But now, when I want to edit some article, I get the following error:</p>

<p><strong>No query results for model [App\Article].</strong></p>

<p>For example, when I try to open the following: <code>www.example.com/some_slug/edit</code> - I get that error.</p>

<p>So, method ArticleController@show(Article $article) works fine, but ArticleController@edit(Article $article) doesn't work. </p>

<p>Here is my route list:</p>

<p><a href="https://i.stack.imgur.com/YJsoh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YJsoh.png" alt="Rote List"></a></p>

<p>and here are <em>show</em> and edit methods from ArticleController:</p>

<pre><code>public function show(Article $article)  // THIS WORKS FINE
{
    $tags = $article-&gt;tags()-&gt;get();
    return view('articles.show', compact('article', 'tags'));
}

public function edit(Article $article) // DOESN'T WORK -&gt; When I open article/slug/edit I get error: No query results for model [App\Article].
{
    $tags = Tag::lists('name', 'id');
    $categories = Category::orderBy('lft', 'asc')-&gt;get()-&gt;lists('padded_name', 'id');
    return view('articles.edit', compact('article', 'tags', 'categories'));
}
</code></pre>