The categories method is undefined. as I am using Corel package for this and in documentation, they mentioned like below,
Categories and Taxonomies
Get a category or taxonomy or load posts from a certain category. There are multiple ways to achieve it.
// all categories
$cat = Taxonomy::category()->slug('uncategorized')->posts->first();
echo "<pre>"; print_r($cat->name); echo "</pre>";
// only all categories and posts connected with it
$cat = Taxonomy::where('taxonomy', 'category')->with('posts')->get();
$cat->each(function($category) {
echo $category->name;
});
// clean and simple all posts from a category
$cat = Category::slug('uncategorized')->posts->first();
$cat->posts->each(function($post) {
echo $post->post_title;
});
I am using first method but now i want to pass multiple categories and fetch all posts linked with those categories.