Last active
December 24, 2020 20:55
-
-
Save marktopper/ad3f8048a1a7bf55a5fcc747745d92ec to your computer and use it in GitHub Desktop.
[Voyager] Routes for Pages BREAD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PageController extends \App\Http\Controllers\Controller | |
{ | |
public function show() | |
{ | |
$slug = request()->segment(1); | |
$page = \TCG\Voyager\Models\Page::where('slug', $slug) | |
->firstOrFail(); | |
return view('show-page', [ | |
'page' => $page, | |
]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
try { | |
$pages = \TCG\Voyager\Models\Page::all(); | |
foreach ($pages as $page) { | |
Route::get($page->slug, 'PageController@show'); | |
} | |
} catch (\Exception $exception) { | |
// do nothing | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>{{ $page->title }}</h1> | |
<?php echo $page->body; ?> |
How about :
Route::get('/pages/{slug}', 'PagesController@getPage'); <-- web.php
public function getPage($slug)
{
$page = DB::table('pages')->where('slug', $slug)->firstOrFail();
return view('pages/index', ['page' => $page]);
}
Hi @marktopper how to modification Post admin page , I will install or add module tags in post add,
btw I uses : https://cartalyst.com/manual/tags/4.0#adding-tags
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks Mark - worked for me too. This stuff really needs to be added to the official docs!