title: how to edit column on laravel?
body: <p>I'm working with Laravel 5.1 + datatables (<a href="http://datatables.yajrabox.com/" rel="nofollow">http://datatables.yajrabox.com/</a>). </p>
  
  <p>I need to edit column user_id and show the firstname and lastname from relationships. </p>
  
  <p>There is my code.</p>
  
  <pre><code>public function getOrders(Request $request){
    if($request-&gt;ajax()) {
         $orders = Order::with('call', 'contact.company', 'campaign')
                          -&gt;Client()-&gt;Finished()-&gt;get();
  
         return Datatables::of($orders)-&gt;editColumn('user_id', 
                   function ($orders) {
                        return $orders-&gt;User-&gt;firstname.' '.$orders-&gt;User-&gt;lastname;
                    })-&gt;make(true);
     }                    
  
     return view('global/orders');
  }
  </code></pre>
  
  <p>And there is my datatables.js call:</p>
  
  <pre><code>var oTable = $('#orders-data').dataTable({
          "processing": true,
          "serverSide": true,
          "ajax": '/history/orders',
          "columns": [
              { data: 'created_at', name: 'created_at' },
              { data: 'user_id', name: 'user_id' },
              { data: 'call.phone', name: 'phone' },
              { data: 'contact.first_name', name: 'first_name' },
              { data: 'contact.last_name', name: 'last_name' },
              { data: 'contact.company.name', name: 'company' },
              { data: 'contact.address', name: 'address' },
              { data: 'contact.postal', name: 'postal' },
              { data: 'contact.city', name: 'city' },
              { data: 'contact.country', name: 'country' },
              { data: 'campaign.name', name: 'name' },
              { data: 'call.call_length', name: 'call_length' },
              { data: 'call.comment', name: 'comment' },
              { data: 'call.status', name: 'status' },
              { data: 'call.full_record', name: 'full_record' },
              { data: 'action', name: 'action', orderable: false, searchable: false }
          ]
  });
  </code></pre>
  
  <p>But on this <code>$orders-&gt;User-&gt;firstname</code> I got 10 queries </p>
  
  <pre><code>select * from `users` where `users`.`id` = 'x' limit 1
  </code></pre>
  
  <p>How to edit columns with relationships on <code>$orders = Order::with('user', 'call', 'contact.company', 'campaign')-&gt;Client()-&gt;Finished()-&gt;get();</code> ?</p>