title: How to get the value from another table using id with Ajax and Laravel?
body: <p>I was trying Yajra Datatable on Laravel and I found this on the tutorial where I get the values from a single table.<br/>
  I have to compare the values of each column in the 1st table to the 2nd table like for example the 1st tables status is 1, it would check the status types table which status has the id of 1 and in this example 1 is pending so the datatable would be showing &quot;Pending&quot; instead of number 1<br/>
  Below here is the code from the Controller:</p>
  <pre><code>public function index()
  {
      $documents = Documents::all();
      $status = Status::all();
  
      return view('document/index', compact('documents', 'status'));
  }
  
  public function getDocs(Request $request)
  {
      if ($request-&gt;ajax()) {
          $docs = Documents::latest()-&gt;get();
          return Datatables::of($docs)
              -&gt;addIndexColumn()
              -&gt;addColumn('action', function($row){
                  $actionBtn = '&lt;a href=&quot;javascript:void(0)&quot; class=&quot;edit btn btn-success btn-sm&quot;&gt;Edit&lt;/a&gt; &lt;a href=&quot;javascript:void(0)&quot; class=&quot;delete btn btn-danger btn-sm&quot;&gt;Delete&lt;/a&gt;';
                  return $actionBtn;
              })
              -&gt;rawColumns(['action'])
              -&gt;make(true);
      }
  }
  </code></pre>
  <p>Here is from the document/index view:</p>
  <pre><code>$(function () {
  
      var table = $('.yajra-datatable').DataTable({
          processing: true,
          serverSide: true,
          ajax: &quot;{{ route('documents.list') }}&quot;,
          columns: [
              {data: 'id', name: 'id'},
              {data: 'status', name: 'status'}
          ]
      });
  
  });
  </code></pre>