thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.72k stars 2.67k forks source link

whereTranslation for just active language #5770

Open ahmetsmc opened 1 year ago

ahmetsmc commented 1 year ago

Laravel version

9.22

PHP version

8.1.4

Voyager version

1.6.x-dev

Database

5.7.42

Description

I have translatable Post model and table and i have 2 locale(de, en).

I am using for translate:

$post = Post::whereTranslation("slug", $slug)->firstOrFail()->translate();

This gives the correct result but my problem is i dont want alternative locale. So, locale is de then just tranlsate for de.

I tried this but not working:

$page = Page::whereTranslation('slug', '=', $slug, [app()->getLocale()], false)->firstOrFail()->translate();

When I try this way, it always returns 404. Where is the problem, does anyone have any ideas or is this a problem?

Steps to reproduce

.

Expected behavior

.

Screenshots

No response

Additional context

No response