Many to many showing only few rows

Posted 10 months ago by arctushar

I have Two models with three table. Models are Node & Tag. And have Three tables named- nodes, tags, node_tag. My Node Model code is as below

    public function tags(){
        return $this->belongsToMany('App\Tag');
    }

My Tag model code is as below

    public function nodes(){
        return $this->belongsToMany('App\Node');
    }

When I call in controller as below

return $node=Node::find(1723)->tags;

this is showing only two rows. But when I call in controller as below

return $user = DB::table('node_tag')->where('node_id', 1723)->get();

It shows four rows. What is the problem ?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.