I need a bit of help in showing user the ads of the those categories that he has seen previously. Its more like suggestion system, the system should generate a intelligent combination of most viewed and new categories. We are recording the ads view and we have categories of viewed ads
Ads.php
class Ads extends Model
{
public function category(){
return $this->belongsTo(Category::class , 'category_id');
}
}
Adcounts.php -> Used as pivot for storing views and categories
class adcounts extends Model
{
public function ad(){
return $this->belongsTo(Ads::class , 'post_id');
}
public function category(){
return $this->belongsTo(Category::class , 'category_id');
}
}
Category.php
class Category extends Model
{
public function ads(){
return $this->hasMany(Ads::class);
}
}
What I need is to show the user ads of those categories which he has seen previously.