-
-
Save gnovaro/2d7c7559fdad6d8c0bace1be92341f19 to your computer and use it in GitHub Desktop.
[Voyager] Routes for Pages BREAD
This file contains hidden or 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 | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
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 hidden or 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 hidden or 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> | |
{!! $page->body !!} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment