Ratio to the table through another table in Eloquent



  • There are three tables: "Users," "Subscriptions," "Packages." Table Users has one to One to Table Subscriptions through Subscriptions.user_id. Table "Subscriptions" has one to One to Table "Packages" through Subscriptions.package_id. The question is, how do you connect the Users table to the table "Packages" with a relationship function in Laravel Eloquent?



  • Don't do that. Get both documentation to subscriptions, then you can access the chain. In your case, you can access the Users-subscriptions-statepackages. So you're only making a direct relationship. But having access to another model through attitude, you get access to her fields, and her resignations, too, which means you can get access to anything quickly in 10 relationship tables.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2