title: Getting database information in Laravel Blade Template with Inner Join
body: <p>This question has to do with Laravel, but also general database design as well since I am new to both.</p>
  
  <p>I have made a database that is like this:</p>
  
  <p>people</p>
  
  <ul>
  <li>id</li>
  <li>firstname</li>
  <li>lastname</li>
  <li><strong>address</strong></li>
  <li>yadayada</li>
  </ul>
  
  <p>address</p>
  
  <ul>
  <li><strong>id</strong></li>
  <li>line1</li>
  <li>city</li>
  <li>state</li>
  <li>zip</li>
  <li>yadayada</li>
  </ul>
  
  <p>There is a "people" and it can have an address. I have split this way because company (another section of this app) will also have addresses, as well as meeting place and POI will have an address too. I am building a CRM type system. Now, I need to retrieve the information from the database. But there is a problem because there are 2 columns named "id".</p>
  
  <p>My Inner Join is as follows. And it works:
              $people = DB::table('people')
                  ->join('address', 'address.id', '=', 'people.address')
                  ->get();</p>
  
  <pre><code>        return View::make('people.index')
              -&gt;with('people', $people);  
  </code></pre>
  
  <p>But when I go to my Laravel Blade template everything works fine the Inner Join is successful and the data is displayed, but I need to create a Resourceful Controller link which links to the ID so that it can be viewed on its own page:</p>
  
  <pre><code>        @foreach ($people as $people)
              &lt;li&gt;
                  &lt;a href="{{ URL::to('people/' . $people-&gt;id) }}" class="thumbnail"&gt;
                      &lt;img src="" /&gt;
                  &lt;/a&gt;
                  &lt;div class="caption"&gt;
                      &lt;p&gt;
                          {{ $people-&gt;firstname }}&lt;br /&gt;
                          {{ $people-&gt;lastname }}&lt;br /&gt;
                          {{ $people-&gt;line1 }}&lt;br /&gt;
                          {{ $people-&gt;city }}&lt;br /&gt;&lt;br /&gt;
  
  &lt;/p&gt;
              &lt;/li&gt;
          @endforeach
  </code></pre>
  
  <p>Which returns very crazy results because it doesn't know which "id" to use. (It is using the address table's id with weird results)</p>
  
  <ol>
  <li><p>Is there a way to specify a table name in Laravel? (This does not work):</p>
  
  <pre><code>    &lt;a href="{{ URL::to('people/' . $people-&gt;people.id) }}" class="thumbnail"&gt;
          &lt;img src="" /&gt;
      &lt;/a&gt;
  </code></pre></li>
  <li><p>Or is it general good database practice not to use "id" in two different tables? in which case I could rename and the problem would be fixed</p></li>
  </ol>
  
  <p>Thank you for your help.</p>