A
A
Alexander2019-11-23 23:21:19
Laravel
Alexander, 2019-11-23 23:21:19

How to display data from different models on one page in laravel?

Good evening. There are three models: posts, categories and tags whose information needs to be displayed on one page, for example, editing a post.
Question: how to implement this feature in the right way in laravel?
It is clear that I can collect the data I need from three tables in one controller method and pass it to the view, but in this case, at least I lose flexibility, and at the maximum, this method seems to me not correct from the point of view of code architecture.
Please correct me if I'm wrong somewhere. Thanks for the help!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2019-11-24
@bitw

And what prevents you from making relays in the model and creating a resource through which to give the necessary data, taking into account the connections.
The session will process the data from the model. Pass it to the template

A
Anton Shamanov, 2019-11-24
@SilenceOfWinter

data from three tables in one controller method and pass them to the view, but in this case, at least I lose my flexibility, and as a maximum, this method seems to me not correct from the point of view of the code architecture.

if data from tables means models, then this is exactly what is needed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question