title: Laravel - Creating a Dynamic URL using a Database String
body: <p>I am with a bit of a stuggle here. I managed to create the dynamic URL using the following code: </p>
  
  <p><em>Home Page Controller</em></p>
  
  <pre><code>$satellites = DB::table('satellites')-&gt;get();
  return view('pages/home', ['satellites' =&gt; $satellites]);
  </code></pre>
  
  <p><em>Blade File</em></p>
  
  <pre><code>@foreach($satellites as $satellite)
      &lt;a href="{{$satellite-&gt;norad_cat_id}}"&gt;&lt;li&gt;{{$satellite-&gt;satname}}&lt;/li&gt;&lt;/a&gt;
  @endforeach
  </code></pre>
  
  <p><em>web.php</em></p>
  
  <pre><code>Route::get('{norad_cat_id}', 'Satellite@show');
  </code></pre>
  
  <p><em>Controller</em></p>
  
  <pre><code>public function show($norad_cat_id)
  {
      return view('pages/satellite');
  }
  </code></pre>
  
  <p>The URL generated is: mysite.com/12345 (where 12345 is the norad_cat_id).</p>
  
  <p>This code manages to create the dynamic URLs using the norad_cat_id from the database - which is what I want. The problem is that I can replace the URL with anything and it still creates a page (ie. replace the 12345 with something not from the database and a page is still created). </p>
  
  <p>What I want is only for a URL to be generated only with the norad_cat_id and if there is no matching norad_cat_id in the database, display a 404 page.</p>