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

melx's avatar
Level 4

display 4 or more different tables in one view page

i want to display a different tables(table1, table2, table 3, table 4) in one view and and print it as one page

do i need a different controller or one controller? and how the sample code looks like in that controller?

I need just an idea

0 likes
2 replies
Sergiu17's avatar

One controller is fine.

public function report()
{
    $set1 = Model::all();
    $set2 = Model2::all();
    // ....

    return view('report', compact('set1', 'set2', '...');
}
Punksolid's avatar
Level 25
public function showAll() {
    $posts = PostModel::all();
    $comments = CommentModel::all();
    $users = UserModel::all();
    $accounts = AccountModel::all();

    return view('views.all')->with(compact('posts','comments','users','accounts'));
}

You do all in one controller. However you should paginate them.

Please or to participate in this conversation.