PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Question By
Solved

Show n posts from a specific category in homepage

Solved
francescomulassano1

Dec 23rd, 2022 05:30 AM

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

francescomulassano1

Dec 23rd, 2022 06:50 AM

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'));
    }
}
bobbyiliev

Dec 23rd, 2022 09:56 AM

Best Answer

Hi there,

Yep, this looks good!

Let me know if anything else pops up!

Best,

Bobby