Untitled
user_5905108
php_laravel_blade
a year ago
707 B
20
No Index
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