Search code examples
laraveleloquenteager-loading

How to eager load on different connections in Laravel


I have 3 database connections. Let's say con1, con2, con3.

  • con1

    • table1
    • table4
  • con2

    • table2
  • con3

    • table3

Below is a sample of my code. This code does not work and returns the error below. My other relations are working fine so I think the db connection might be the problem. if I remove the eager loading -- with(['table4', 'table2']) -- it works.

table1::with(['table4', 'table2.table3'])
      ->get();

Error image


Solution

  • Nevermind. turns out my code is working. The error just indicates that the data can't be shown in preview because the response is too huge