title: Laravel routing by looping through array
body: <p>I am trying to use the Route::get method to setup the URL structure for my application without repeating Route::get for each item. I am doing this with a foreach loop as follows: </p>
  
  <pre><code>&lt;?php
  
  Route::get('/', function () {
      return view('welcome');
  });
  $pages = array('about', 'contact', 'faqs');  
  foreach ($pages as $page) {
      Route::get($page, function () {
          return view($page);
      });
  }
  </code></pre>
  
  <p>When run I come across the error: "Undefined variable: page". Although I have worked much with procedural PHP, and PHP within CMSs, I am fairly new to Laravel. What am I missing here? </p>