title: How to show one by one record two different tables in one datatable using laravel
body: <p>I want to show record from two different tables in one datatable , I have only shown one table record in datatable please help me how can i merge two different table in one datatable ? thank u.</p>
  <p><strong>Controller</strong></p>
  <pre><code>public function index()
      {
           $booking = Booking::where('user_id',Auth::user()-&gt;id)-&gt;pluck('id');
  
           $bookingUserPayment = BookingPayments::with('booking.rooms','booking.users')-&gt;whereIn('booking_id',$booking)-&gt;get();
           $shopPayment    = ShopPayment::where('user_id',Auth::user()-&gt;id)-&gt;get();
          $data=[
                  'bookingUserPayment' =&gt;$bookingUserPayment,
                  'shopPayment'  =&gt; $shopPayment
          ];
  
          return view('web.payment',$data);
      }
  </code></pre>
  <p><strong>Html view</strong></p>
  <pre><code>&lt;div class=&quot;row&quot;&gt;
        &lt;div class=&quot;col-md-12&quot;&gt;
          &lt;div class=&quot;card&quot;&gt;
            &lt;div class=&quot;card-body&quot;&gt;
              &lt;h5 class=&quot;fw-bold mb-4&quot;&gt;Payment History&lt;/h5&gt;
              &lt;table class=&quot;table&quot; id=&quot;payment-dataTable&quot; &gt;
                &lt;thead&gt;
                  &lt;tr&gt;
                    &lt;th scope=&quot;col&quot;&gt;Booking Slot&lt;/th&gt;
                    &lt;th scope=&quot;col&quot;&gt;Item&lt;/th&gt;
                    &lt;th scope=&quot;col&quot;&gt;Amount (RM)&lt;/th&gt;
                    &lt;th&gt;&lt;/th&gt;
                  &lt;/tr&gt;
                &lt;/thead&gt;
                &lt;tbody&gt;
                    @if(count($bookingUserPayment) &gt; 0)
                  @foreach ($bookingUserPayment as $bookingUserPayments)
                      @foreach ($bookingUserPayments-&gt;booking as  $bookings)
                          &lt;tr&gt;
                          @php
                              $date = date(&quot;d-M-Y H:i&quot;, strtotime($bookingUserPayments-&gt;payment_date));
                          @endphp
                              &lt;td&gt;{{ $date}}&lt;/td&gt;
                              &lt;td&gt;{{$bookings-&gt;rooms[0]-&gt;name}}&lt;/td&gt;
                              &lt;td&gt;{{number_format($bookings-&gt;price)}}&lt;/td&gt;
                          &lt;/tr&gt;
                      @endforeach
                  @endforeach
                  @endif
                &lt;/tbody&gt;
              &lt;/table&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>