I have two models. i.e, Posts
and Tags
.
Post Model
public function tags()
{
return $this->belongsToMany('App\Models\Tag', 'tbl_post_tags', 'in_post_id', 'in_tag_id');
}
Tag Model
public function posts()
{
return $this->belongsToMany('App\Models\Post', 'tbl_post_tags', 'in_tag_id', 'in_post_id');
}
I want to fetch those posts which have php
tag.
This is what I have done till now.
Search Controller
Post::with(['tags'])->skip(0)->take(5)->get();
I'm getting first five posts from table. But there is a post in these list which doesn't have PHP
tag. So as per my requirement, I must get next post from table which have PHP
tag.
I can't find any document on official site of laravel. If anyone knows the answer, it will be appreciated.