Hello. I've read documentation few times and can't figure out the following problem.
I have 3 tables:
'accesses' table with columns:
id,
product_user_id
'product_user' table:
id (this one is used by accesses)
user_id
product_id
'product' table:
id (used by product_user)
I wanna use relations for Elaquent models.
I need to get all accesses for products for specific user_id.
I do know i can use belongsToMany or hasOneThrough to query accesses related to specific product. But how can i filter this by user_id?
The second problem is i have 3rows for specific user_id in product_user table.
Can i do something like ProductUser::where('user_id',7)->product->accesses->get()
Or can i do Product::all()->accesses and then somehow apply filter by user_id?