title: Display Category Slug in URL Instead of ID
body: <p>I'm relatively new to Laravel, and I have found myself stuck trying to display category slugs instead of the ID.</p>
  
  <pre><code>eg: www.website/.../category-slug
  </code></pre>
  
  <p>My website currently shows  www.website/.../category-id. I have a categories table and a posts table with columns.</p>
  
  <pre><code>posts table = | id | title | body | img | post_category_id|
  
  post_categories table = | id | name | catslug |
  </code></pre>
  
  <hr>
  
  <p><strong>Controller</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>public function getPostCategory($id)
  {
      $postCategories = PostCategory::with('posts')
          -&gt;orderBy('name', 'asc')
          -&gt;get();
  
      $posts = Post::orderBy('id', 'desc')
          -&gt;where('post_category_id', $id)
          -&gt;paginate(5);
  
      return view('articles.category.categoriesposts')-&gt;withPosts($posts)-&gt;with('postCategories', $postCategories);
  }
  </code></pre>
  
  <hr>
  
  <p><strong>Route</strong></p>
  
  <pre><code>Route::get('articles/category/{id}', [ 
      'uses'  =&gt;  'ArticlesController@getPostCategory',
      'as'    =&gt;  'pcategory'
  ]);
  </code></pre>
  
  <p>I've tried many methods, but nothing seems to work. Any help would be appreciated.</p>
  
  <p>Many thanks,</p>
  
  <p>Ash</p>