-
app/Http/Controllers/PostController.php
Open in GitHubuse App\Models\Post; use Illuminate\Support\Facades\Auth; final class PostController { public function __invoke(Post $post) { abort_if(Auth::guest() && $post->isUnpublished(), 404); $previous = $post->previous(); $next = $post->next(); return view('post', compact('post', 'previous', 'next')); } }
-
routes/web.php
Open in GitHubRoute::get('/blog/{post:slug}', PostController::class)->name('post');