I get a query exception when retrieving my post by slug in my controller
I have in Post model:
public function getRouteKeyName()
{
return 'slug';
}
I declare slug as a translatable field in post_translations migration
When I retrieve a Post with route binding in my controller:
public function show(Post $post)
{
it throws the query exception shown
I am using Laravel 8.
The exception shows how is trying to retrieve the field from posts table instead of posts_translations:
Query exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'slug' in 'where clause' (SQL: select * from posts where slug = XXX
I get a query exception when retrieving my post by slug in my controller
I have in Post model: public function getRouteKeyName() { return 'slug'; }
I declare slug as a translatable field in post_translations migration
When I retrieve a Post with route binding in my controller: public function show(Post $post) { it throws the query exception shown
I am using Laravel 8.
The exception shows how is trying to retrieve the field from posts table instead of posts_translations: Query exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'slug' in 'where clause' (SQL: select * from
posts
whereslug
= XXX