Mevcut Rotam ve Slug kodlarım, buna kategoriyi de ilave edersek harika olacak :)
Route :
Route::get('blog/{slug}', 'BlogController@show');
BlogController :
public function show($slug)
{
$post = Post::findBySlug($slug);
return view('post.single', ['post' => $post]);
}
Post Model :
public function category()
{
return $this->belongsTo(Category::class, 'category_id');
}
public static function findBySlug($slug) {
return static::where('slug', $slug)->first();
}