Can I create a model responsible for more than one table in Laravel?

Asked

Viewed 23 times

1

I wonder if I can create a model that returns the result of more than one table in Laravel.

  • 1

    No, in a model you will treat the data of a table, and also treat the relationships of that table with others as can be seen in documentation

2 answers

0

0

First it is worth mentioning that each model is responsible for a table in Laravel.

There are ways you can do this but with different tools, you can see here in this link from S.O itself(In English), more details on how to do this.

You can create an auxiliary table and recover the data with the Relationships of the Variable.

Anyway, there are several ways you can recover this information, just take a look at the documentation and go testing to see which one is better for your application.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.