title: Passing Data In Laravel With Eloquent
body: <p>We have a backend for our business written in good old PHP, we are now wanting to try to redo it in Laravel but are having problems making the jump.</p>
  
  <p>I have read tons of tutorials but seem to be having trouble finding one that relates. We have a database full of records and for the first page we just want to print them all out into a table.</p>
  
  <p>In regular php we just run a query, put that into an array and parse out the data. I tried doing that in the view controller but am having little success...</p>
  
  <p>The table format may be slightly off just trying to get the data printed for now, also routes and everything work.</p>
  
  <p>I am not 100% on if everything is set up in the ideal place or if this is the ideal way to do it but here is what we have:</p>
  
  <p>Thanks in advance for the help!</p>
  
  <pre><code>// Model:'PaymentInfo' - Database Table: 'payment_info'
  
  Class PaymentInfo extends Eloquent
  {
  
      public $connection = 'main';
  
      protected $table = 'payment_info';
  
      protected $primaryKey = 'order_id';
  
      public function getLastname()
      {
          return $this-&gt;lastname;
      }
  
      public function getFirstname()
      {
          return $this-&gt;firstname;
      }
  
      public function getBuyerEmail()
      {
          return $this-&gt;buyer_email;
      }
  
      public function getCountry()
      {
          return $this-&gt;country;
      }
  
  
      public function getMcGross()
      {
          return $this-&gt;mc_gross;
      }
  </code></pre>
  
  <p>Then the Controller:</p>
  
  <pre><code>class AdminController extends BaseController {
  
      /**
       * Display a listing of the resource.
       *
       * @return Response
       */
      public function getIndex()
      {
          return View::make('admin.index');
      }
  
  }
  </code></pre>
  
  <p>Finally the view:</p>
  
  <pre><code>@extends('master')
  
  @section('content')
  
  &lt;div class="span 8 well"&gt;
  
      &lt;h4&gt;Hello {{ (Auth::user()-&gt;username) }}&lt;/h4&gt;
  
  &lt;/div&gt;
  
  &lt;div&gt;
      &lt;div style="font-size:medium"&gt;
      &lt;h1&gt;
      &lt;center&gt;Recent Orders&lt;/center&gt;
      &lt;/h1&gt;
  &lt;/div&gt;
  &lt;div id="highstyle1"&gt;
  &lt;table border="1" cellspacing="0" cellpadding="4"&gt;
  &lt;tr&gt;
      &lt;th&gt;Order #&lt;/th&gt;
      &lt;th&gt;Buyer Name&lt;/th&gt;
      &lt;th&gt;Email Address&lt;/th&gt;
      &lt;th&gt;Country&lt;/th&gt;
      &lt;th&gt;Payment&lt;/th&gt;
      &lt;th&gt;Buyer Memo&lt;/th&gt;
      &lt;th&gt;Order Date&lt;/th&gt;
      &lt;th&gt;Status&lt;/th&gt;
      &lt;th&gt;Transaction ID&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      {{ $order_id = PaymentInfo::all() }}
  
      @foreach ($order_id as $order)
          &lt;td&gt;{{ PaymentInfo::$order-&gt;lastname }}&lt;/td&gt;
      @endforeach
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  
  &lt;/div&gt;
  
  @stop
  </code></pre>