Untitled

user_5905108 avatar
user_5905108
Laravel Blade
06/24/2024 12:27 AM
707 B
28
No Index
Never
In the routes/web.php look for this:

//Sitemap
Route::get('/sitemap.xml', [SitemapController::class, 'index'])->name('sitemap');
Route::get('/{slug}', [WebsiteController::class, 'show'])->name('page');  <!-- Add this line -->

In the app/Http/Controllers/Frontend/WebsiteController.php, after the index() function, add the show() function

    public function index()
    {
        ...
    }

    public function show($slug)
    {
        $pages = Pages::all();
        $page = Pages::whereSlug($slug)->firstOrFail();
        return view('frontend.pages.index', compact('pages', 'page'));
    }

That is it. All pages which are dynamically created inside the Adminpage are now working without hardcoding.

Editor is loading...
Leave a Comment