title: Getting url data to show in the url bar
body: <p>I'm using Laravel 4 and I'm trying to get the url bar to display the text url that is saved in the database instead of using the id.</p>
  
  <p>This is my routes.php</p>
  
  <pre><code>Route::get('/{id}', function($id = 1){
  
  if(is_numeric($id))
  {
  
      $page = Menu::find($id);
      $action = 'content';
      return App::make('HomeController')-&gt;$action($id);
  } else {
      $column = 'url';
      $url = Seo::where($column, '=', $id)-&gt;get();
      $action = 'show';
      return App::make('HomeController')-&gt;$action($url[0]-&gt;id);
  }   
  });
  </code></pre>
  
  <p>I'm also using a pivot table to link the menu to the seo.</p>
  
  <p>Seo model</p>
  
  <pre><code>&lt;?php
  
  class Seo extends \Eloquent {
  protected $fillable = array('url', 'meta_title', 'meta_description', 'keywords');
  protected $guarded = array('id');
  
  protected $table = 'seo';
  
  public static $rules = array(
      'title' =&gt; '',
      'content' =&gt; '',
      'image' =&gt; ''
  );
  
  public function menu(){
      return $this-&gt;belongsToMany('Menu', 'menu_seo', 'seo_id', 'menu_id');
  }
  }
  </code></pre>
  
  <p>Menu model</p>
  
  <pre><code>&lt;?php
  
  class Menu extends \Eloquent {
  protected $fillable = array('title', 'menu_id', 'image');
  protected $guarded = array('id');
  
  protected $table = 'menus';
  
  public static $rules = array(
  
      );
  
  public function seo(){
      return $this-&gt;belongsToMany('Seo', 'menu_seo', 'menu_id', 'seo_id');
  }
  }
  </code></pre>
  
  <p>HomeController</p>
  
  <pre><code>public function content($id)
  {
  
      $menus_child = Menu::where('menu_id', 0)-&gt;with('menusP')-&gt;get();
  
      $menu = Menu::where('id', $id)-&gt;firstOrFail();
  
      //dd($menu-&gt;frames);
      return View::make('index', compact('menus_child'))-&gt;with('menu', $menu);
  }
  </code></pre>
  
  <p>and then I call my views that references the menu like this</p>
  
  <pre><code>@foreach($menu-&gt;banner as $banners)
  {{ $banners-&gt;title }}
  @endforeach
  </code></pre>