-
-
Save Rndwiga/ca7e0b460c2384da0b60d6c680ace9ff 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; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment