i'm trying to make an blog application with laravel. my problem is that i have listed my posts in allnews.blade.php view and i described texts as routeable to detail pages of post but it doesn't work
allnews.blade.php
@foreach ($posts as $post) // this is allnews.blade.php view
<li>
<div class="media wow fadeInDown">
<a href="{{$post->slug}}" class="container"> <img width="100%" height="auto" alt=""
src="/storage/{{ $post->image}}"> </a>
<div class="media-body"> <h3 src="" class="catg_title">{{$post->title}}</h3> </div>
</div>
</li>
@endforeach
but when i try to go to my post detail(by using href $post->slug ) i'm having issues with "404 page not found" problem. for my logic all things look perfect. but i cant route.
here is my PostController.php
public function DetailofPost($id)
{
$PostDetails = Post::where('slug' , $id)->first();
return view('PostDetail', compact ('PostDetails'));
}
here is my PostDetail.blade.php view
@foreach($PostDetails as $PostDetail)
<h1>{{PostDetail->title}}</h1>
<div class="single_page_content"> <img class="img-center" src="/storage/{{ $PostDetail->image}}" alt="">
<blockquote> {{PostDetail->body}}</blockquote>
@endforeach
and here is my routing page a.k.a web.php
Route::get('/', function () {
return view('welcome');
});
Route::get("/tumhaberler" , 'PostController@ListAll');
Route::group(['prefix' => 'admin'], function () {
Voyager::routes();
});
Route::get('/{slug}', 'PostController@DetailofPost');
allnews.blade.phpview? you should avoid relative URLs, this is why we have URL helpers ... this seems like an issue of not knowing how relative URLs work with the current base URL - lagbox