Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rajatsharma2122's avatar

In my view i am fetching data from 5 tables ( Later stage it can we increased to 15) and want to pass data in blade view so that my PDF file can be generated.In my view i am fetching data from 5 tables ( Later stage it can we increased to 15) and want to

In my view i am fetching data from 5 tables ( Later stage it can we increased to 15) and want to pass data in blade view so that my PDF file can be generated.In my view i am fetching data from 5 tables ( Later stage it can we increased to 15) and want to pass data in blade view so that my PDF file can be generated.

Now in blade view i only want to generate the report based on data. Let's say i have data coming from only four tables then corresponding section will populated with data from the array sent from controller. How this can be achieved.

How to get access the data in larvael blade view for these one arrays. this is sample data

  0 => Collection {#646 ▼
    #items: array:3 [▼
      0 => Fieldday {#647 ▶}
      1 => Fieldday {#648 ▶}
      2 => Fieldday {#649 ▶}
    ]
  }
  1 => Collection {#643 ▼
    #items: array:2 [▼
      0 => Onfarmtrials {#645 ▶}
      1 => Onfarmtrials {#636 ▶}
    ]
  }
  2 => Collection {#650 ▼
    #items: array:1 [▶]
  }
  3 => Collection {#641 ▶}
  4 => Collection {#642 ▶}
  5 => Collection {#665 ▶}
  6 => Collection {#672 ▶}
  7 => Collection {#670 ▶}
  8 => Collection {#652 ▶}
]


Is there any other better option / method
P.S i dont want to pass the separate array in view.
0 likes
1 reply
Snapey's avatar

Please edit your question and your first reply so that they make sense.

Please format your code by putting 3 backticks ``` on a line before and after each code block

What you are describing (iterating over arrays in a view) is performed by almost all applications and blade has good helpers to help you do it with both foreach loops and partials. Please check the blade documentation.

https://laravel.com/docs/5.8/blade

Please or to participate in this conversation.