How to get related post from blog by category id



  • How to get related post from blog by category id



  • private $category;
    private $setting;

    public function __construct(CategoryRepository $category, Setting $setting)
    {
        $this->category = $category;
        $this->setting = $setting;
    }
    

    $paginate = $this->setting->get('blog::posts-per-page', locale());
    $posts = $this->category->find($categoryId)->posts()->paginate($paginate);


Log in to reply
 

Looks like your connection to AsgardCms was lost, please wait while we try to reconnect.