The route used to open the single blog:
Route::get('/blog/{title}', 'EdificController@showblog');//single blog view
The main blog blog route that lists all the blogs
Route::get('/blog', 'EdificController@blog')->name('blog');//blog view
The controller( front-end) to show the single blog
public function showblog( $title)
$blog = Blog::find($title);
return view('edific.show-blog', compact('blog', 'blogcomments', 'blogreplies'));
}
The code to call the single blog via the read more:
<a href="/blog/" class="post-meta">Read More</a>
when i click the link i get the error
Trying to get property 'image' of non-object (View: C:\laragon\www\edi-fic-1.0.0\resources\views\edific\show-blog.blade.php)
What I want is that instead of calling the id e.g 1 (http://127.0.0.1:8000/blog/**1**) it should open using the title of the blog.The id should not be seen
source https://stackoverflow.com/questions/68971922/how-can-i-pass-the-title-of-the-blog-instead-of-the-id-in-readmore-in-laravel
Comments
Post a Comment