Chron's avatar
Level 7

Accessing models by using the pivot table

Is there a way to access the relationships of the pivot table?

For example:

Model1 -> Pivot -> model 2
		     |
		     V
		model 3

Is there a way to make it like this?

Model1::with('pivot.' ['model2, model3'])->get()

So the output should be like this:

all: [
	Model1 {
		...
		pivot{
			model2 {
				...
			},
			model3 {
				...
			}
		}
	},
]
0 likes
1 reply

Please or to participate in this conversation.