I'm new at Laravel and I want some help with a Query. Here is my situation. I have 4 tables:
- users (id, email, password.....)
- user_profile (id, first_name, last_name,........, user_id)
- companies (id, name,.......)
- policies (id, policy_num, exp_date,........., user_id, company_id)
The table user have 5 users and every user have 10 policies. The table company have 3 companies.
->where('id', '=', $userId)
This code is working good, it retrieves the all the users and user_profile fields and all the policies(10) of this user with as you can see in this image, and I can show the user the details of the products on a home page.
I want to instead of appear the company_id from the policies table appears the name of the company from the company table.
Any help is appreciated.