Is it recommended to use Laravel as a website framework for blog posts etc.?
No issue if you want to build all of the logic associated with drafting and publishing blog posts etc., but there are ready-made solutions for this already. As a learning exercise, it is a well-trodden path!
How can I achieve something similar please? Perhaps the id should be a string with the actual title?
You can use a slug of the post title as the identifier in the URL. Wherever you create a Post, you would dynamically determine the slug from its title (e.g. using Str::slug($post->title)) and persist that in a slug column on the posts table. If you use Laravel's Route Model binding, you can set to route key name to slug rather than the default id,
// app/Post.php
public function getRouteKeyName()
{
return 'slug';
}
or if you prefer you can simply make the query yourself.
public function show($slug)
{
$post = Post::where('slug', $slug)->firstOrFail();
// return the view with the Post
}
You will need to ensure that a slug is unique for you application, so that the correct post is returned - there are packages that can help with this.