A
A
AaronOrtega2021-01-22 18:35:25
Laravel
AaronOrtega, 2021-01-22 18:35:25

How to pass multiple controllers to laravel route?

Hello everyone
There are two controllers and two models
User/Company , of
course they are interconnected
. But when you go to a certain page, you need to display ALL users and ALL companies.
And in different lists.
Relationships - One company to many Users
on the same page should be both all companies and users, for example:

Route::get('/all', [UsersController::class, 'getUsers']);

In this case, we can get users thanks to relationships with another model - the company,
but ...
on the same page, we need to display ALL COMPANIES
So far, only one thing has come to mind: Make it a crutch. Take all users, sort through them, put unique companies into an array - sort through the array - display, but I didn’t find
this crutch in the documentation, or I searched badly . Do you have any thoughts?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sanes, 2021-01-22
@Sanes

on the same page we need to display ALL COMPANIES

View Composers

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question