Show n posts from a specific category in homepage
Hi, in wave i want to show the latest 3 posts from the blog in another page i want to show the latest 3 posts from a specific category, how to achieve these results?
Thanks
find a solution, is it right?
<?php
namespace Wave\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Wave\Post;
use Wave\Category;
class HomeController extends Controller
{
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
if(setting('auth.dashboard_redirect', true) != "null"){
if(!Auth::guest()){
return redirect('dashboard');
}
}
$posts = Post::orderBy('created_at', 'DESC')->paginate(3);
$categories = Category::all();
$seo = [
'title' => setting('site.title', 'Laravel Wave'),
'description' => setting('site.description', 'Software as a Service Starter Kit'),
'image' => url('/og_image.png'),
'type' => 'website'
];
return view('theme::home', compact('seo', 'posts', 'categories'));
}
}
Hi there,
Yep, this looks good!
Let me know if anything else pops up!
Best,
Bobby