Stretsh's avatar

Pivot Model usage

Am I correct if I understand that a pivot model can't be used like a normal Eloquent model? For instance:

I can't do

$entry = PostUser::where('user_id', $request->user)->get();

If it should be able to work, is there a relation needed between the Post and User models and PostUser?

The only thing I can see in the docs about pivot models is about using using(). Or am I missing something?

0 likes
3 replies
kenny11's avatar

I suggest you to go over "Laravel From Scratch".

It will help you in the long run

Snapey's avatar

a pivot table won't normally have a model, but there is nothing to stop it having one and using it as a model in its own right

Stretsh's avatar

@kenny11 I went over that series since 5.2, plus What's new in Laravel, since 5.2... Any specific lesson?

Please or to participate in this conversation.