Answer the question
In order to leave comments, you need to log in
Post output via Laravel 5 slug?
If you pass its post_id to $post , then everything works fine:
<a href="{{ url('/post/' . $product->post_id . '/show') }}">SEE POST</a>
...
Route::get('/post/{post}/show', '[email protected]');
...
public function show(Post $post)
{
return view('post/single', compact( 'post') );
}
<a href="{{ url('/post/' . $post->post_slug. '/show') }}"
...
Route::get('/post/{post}/show', '[email protected]');
...
public function show($post_url)
{
$post = Post::where('post_slug', $post_url)->get();
return view('post/single', compact( 'post') );
}
Answer the question
In order to leave comments, you need to log in
Instead of
$post = Post::where('post_slug', $post_url)->get();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question